Switch back to the upstream nginx cookbook
chef_nginx is deprecated
This commit is contained in:
29
cookbooks/nginx/recipes/authorized_ips.rb
Normal file
29
cookbooks/nginx/recipes/authorized_ips.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipe:: authorized_ips
|
||||
#
|
||||
# Author:: Jamie Winsor (<jamie@vialstudios.com>)
|
||||
#
|
||||
# Copyright:: 2012-2017, 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'
|
||||
notifies :reload, 'service[nginx]', :delayed
|
||||
end
|
||||
24
cookbooks/nginx/recipes/commons.rb
Normal file
24
cookbooks/nginx/recipes/commons.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipe:: commons
|
||||
#
|
||||
# Author:: AJ Christensen <aj@junglist.gen.nz>
|
||||
#
|
||||
# Copyright:: 2008-2017, 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'
|
||||
37
cookbooks/nginx/recipes/commons_conf.rb
Normal file
37
cookbooks/nginx/recipes/commons_conf.rb
Normal file
@@ -0,0 +1,37 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipe:: common/conf
|
||||
#
|
||||
# Author:: AJ Christensen <aj@junglist.gen.nz>
|
||||
#
|
||||
# Copyright:: 2008-2017, 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']
|
||||
notifies :reload, 'service[nginx]', :delayed
|
||||
variables(lazy { { pid_file: pidfile_location } })
|
||||
end
|
||||
|
||||
template "#{node['nginx']['dir']}/sites-available/default" do
|
||||
source 'default-site.erb'
|
||||
notifies :reload, 'service[nginx]', :delayed
|
||||
end
|
||||
|
||||
nginx_site 'default' do
|
||||
action node['nginx']['default_site_enabled'] ? :enable : :disable
|
||||
end
|
||||
52
cookbooks/nginx/recipes/commons_dir.rb
Normal file
52
cookbooks/nginx/recipes/commons_dir.rb
Normal file
@@ -0,0 +1,52 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipe:: common/dir
|
||||
#
|
||||
# Author:: AJ Christensen <aj@junglist.gen.nz>
|
||||
#
|
||||
# Copyright:: 2008-2017, 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
|
||||
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 'pid file directory' do
|
||||
path lazy { File.dirname(pidfile_location) }
|
||||
mode '0755'
|
||||
recursive true
|
||||
end
|
||||
|
||||
%w(sites-available sites-enabled conf.d streams-available streams-enabled).each do |leaf|
|
||||
directory File.join(node['nginx']['dir'], leaf) do
|
||||
mode '0755'
|
||||
end
|
||||
end
|
||||
|
||||
if !node['nginx']['default_site_enabled'] && platform_family?('rhel', 'fedora', 'amazon')
|
||||
%w(default.conf example_ssl.conf).each do |config|
|
||||
file "/etc/nginx/conf.d/#{config}" do
|
||||
action :delete
|
||||
end
|
||||
end
|
||||
end
|
||||
27
cookbooks/nginx/recipes/commons_script.rb
Normal file
27
cookbooks/nginx/recipes/commons_script.rb
Normal file
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipe:: common/script
|
||||
#
|
||||
# Author:: AJ Christensen <aj@junglist.gen.nz>
|
||||
#
|
||||
# Copyright:: 2008-2017, 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 nxenstream nxdisstream).each do |nxscript|
|
||||
template "#{node['nginx']['script_dir']}/#{nxscript}" do
|
||||
source "#{nxscript}.erb"
|
||||
mode '0755'
|
||||
end
|
||||
end
|
||||
28
cookbooks/nginx/recipes/default.rb
Normal file
28
cookbooks/nginx/recipes/default.rb
Normal file
@@ -0,0 +1,28 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipe:: default
|
||||
#
|
||||
# Author:: AJ Christensen <aj@junglist.gen.nz>
|
||||
#
|
||||
# Copyright:: 2008-2017, 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.
|
||||
#
|
||||
|
||||
nginx_cleanup_runit 'cleanup' if node['nginx']['cleanup_runit']
|
||||
|
||||
include_recipe "nginx::#{node['nginx']['install_method']}"
|
||||
|
||||
node['nginx']['default']['modules'].each do |ngx_module|
|
||||
include_recipe "nginx::#{ngx_module}"
|
||||
end
|
||||
45
cookbooks/nginx/recipes/headers_more_module.rb
Normal file
45
cookbooks/nginx/recipes/headers_more_module.rb
Normal file
@@ -0,0 +1,45 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipe:: headers_more_module
|
||||
#
|
||||
# Author:: Lucas Jandrew (<ljandrew@riotgames.com>)
|
||||
#
|
||||
# Copyright:: 2012-2017, 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']
|
||||
end
|
||||
|
||||
directory module_location do
|
||||
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']}/"]
|
||||
49
cookbooks/nginx/recipes/http_auth_request_module.rb
Normal file
49
cookbooks/nginx/recipes/http_auth_request_module.rb
Normal file
@@ -0,0 +1,49 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipe:: http_auth_request_module
|
||||
#
|
||||
# Author:: David Radcliffe (<radcliffe.david@gmail.com>)
|
||||
#
|
||||
# Copyright:: 2013-2017, 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 Chef::VersionConstraint.new('>= 1.5.4').include?(node['nginx']['source']['version'])
|
||||
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']
|
||||
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
|
||||
43
cookbooks/nginx/recipes/http_echo_module.rb
Normal file
43
cookbooks/nginx/recipes/http_echo_module.rb
Normal file
@@ -0,0 +1,43 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipe:: http_echo_module
|
||||
#
|
||||
# Author:: Danial Pearce (<danial@cushycms.com>)
|
||||
#
|
||||
# Copyright:: 2012-2017, 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']
|
||||
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}"]
|
||||
99
cookbooks/nginx/recipes/http_geoip_module.rb
Normal file
99
cookbooks/nginx/recipes/http_geoip_module.rb
Normal file
@@ -0,0 +1,99 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipe:: http_geoip_module
|
||||
#
|
||||
# Author:: Jamie Winsor (<jamie@vialstudios.com>)
|
||||
#
|
||||
# Copyright:: 2012-2017, 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']
|
||||
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
|
||||
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']
|
||||
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']
|
||||
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'
|
||||
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'"]
|
||||
27
cookbooks/nginx/recipes/http_gzip_static_module.rb
Normal file
27
cookbooks/nginx/recipes/http_gzip_static_module.rb
Normal file
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipe:: http_gzip_static_module
|
||||
#
|
||||
# Author:: Jamie Winsor (<jamie@vialstudios.com>)
|
||||
#
|
||||
# Copyright:: 2012-2017, 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'
|
||||
end
|
||||
|
||||
node.run_state['nginx_configure_flags'] =
|
||||
node.run_state['nginx_configure_flags'] | ['--with-http_gzip_static_module']
|
||||
2
cookbooks/nginx/recipes/http_mp4_module.rb
Normal file
2
cookbooks/nginx/recipes/http_mp4_module.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
node.run_state['nginx_configure_flags'] =
|
||||
node.run_state['nginx_configure_flags'] | ['--with-http_mp4_module']
|
||||
23
cookbooks/nginx/recipes/http_perl_module.rb
Normal file
23
cookbooks/nginx/recipes/http_perl_module.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipe:: http_perl_module
|
||||
#
|
||||
# Author:: Akzhan Abdulin (<akzhan.abdulin@gmail.com>)
|
||||
#
|
||||
# Copyright:: 2012-2017, 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']
|
||||
35
cookbooks/nginx/recipes/http_realip_module.rb
Normal file
35
cookbooks/nginx/recipes/http_realip_module.rb
Normal file
@@ -0,0 +1,35 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipe:: http_realip_module
|
||||
#
|
||||
# Author:: Jamie Winsor (<jamie@vialstudios.com>)
|
||||
#
|
||||
# Copyright:: 2012-2017, 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'
|
||||
notifies :reload, 'service[nginx]', :delayed
|
||||
end
|
||||
|
||||
node.run_state['nginx_configure_flags'] =
|
||||
node.run_state['nginx_configure_flags'] | ['--with-http_realip_module']
|
||||
23
cookbooks/nginx/recipes/http_spdy_module.rb
Normal file
23
cookbooks/nginx/recipes/http_spdy_module.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipe:: http_spdy_module
|
||||
#
|
||||
# Author:: Christoph Buente (<christoph@meinekleinefarm.org>)
|
||||
#
|
||||
# Copyright:: 2013-2017, 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']
|
||||
23
cookbooks/nginx/recipes/http_ssl_module.rb
Normal file
23
cookbooks/nginx/recipes/http_ssl_module.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipe:: http_ssl_module
|
||||
#
|
||||
# Author:: Jamie Winsor (<jamie@vialstudios.com>)
|
||||
#
|
||||
# Copyright:: 2012-2017, 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']
|
||||
33
cookbooks/nginx/recipes/http_stub_status_module.rb
Normal file
33
cookbooks/nginx/recipes/http_stub_status_module.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipe:: http_stub_status_module
|
||||
#
|
||||
# Author:: Jamie Winsor (<jamie@vialstudios.com>)
|
||||
#
|
||||
# Copyright:: 2012-2017, 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'
|
||||
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']
|
||||
21
cookbooks/nginx/recipes/http_v2_module.rb
Normal file
21
cookbooks/nginx/recipes/http_v2_module.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipe:: http_v2_module
|
||||
#
|
||||
#
|
||||
#
|
||||
# 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_v2_module']
|
||||
23
cookbooks/nginx/recipes/ipv6.rb
Normal file
23
cookbooks/nginx/recipes/ipv6.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipe:: ipv6
|
||||
#
|
||||
# Author:: Alan Harper (alan@sct.com.au)
|
||||
#
|
||||
# Copyright:: 2013-2017, 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']
|
||||
46
cookbooks/nginx/recipes/lua.rb
Normal file
46
cookbooks/nginx/recipes/lua.rb
Normal file
@@ -0,0 +1,46 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipe:: lua
|
||||
#
|
||||
# Copyright:: 2013-2017, 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']
|
||||
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
|
||||
EOH
|
||||
not_if { ::File.exist?(luajit_extract_path) }
|
||||
end
|
||||
|
||||
node.run_state['nginx_source_env'].merge!(
|
||||
'LUAJIT_INC' => '/usr/local/include/luajit-2.0',
|
||||
'LUAJIT_LIB' => '/usr/local/lib'
|
||||
)
|
||||
|
||||
node.run_state['nginx_configure_flags'] =
|
||||
node.run_state['nginx_configure_flags'] | ['--with-ld-opt=-Wl,-rpath,/usr/local/lib']
|
||||
46
cookbooks/nginx/recipes/naxsi_module.rb
Normal file
46
cookbooks/nginx/recipes/naxsi_module.rb
Normal file
@@ -0,0 +1,46 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipe:: naxsi_module
|
||||
#
|
||||
# Author:: Artiom Lunev (<artiom.lunev@gmail.com>)
|
||||
#
|
||||
# Copyright:: 2012-2017, 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'
|
||||
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']
|
||||
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"]
|
||||
41
cookbooks/nginx/recipes/ngx_devel_module.rb
Normal file
41
cookbooks/nginx/recipes/ngx_devel_module.rb
Normal file
@@ -0,0 +1,41 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipes:: devel
|
||||
#
|
||||
# Author:: Arthur Freyman (<afreyman@riotgames.com>)
|
||||
#
|
||||
# Copyright:: 2013-2017, 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']
|
||||
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']}"]
|
||||
44
cookbooks/nginx/recipes/ngx_lua_module.rb
Normal file
44
cookbooks/nginx/recipes/ngx_lua_module.rb
Normal file
@@ -0,0 +1,44 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipes:: nginx_lua_module
|
||||
#
|
||||
# Author:: Arthur Freyman (<afreyman@riotgames.com>)
|
||||
#
|
||||
# Copyright:: 2013-2017, 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']
|
||||
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'
|
||||
33
cookbooks/nginx/recipes/ohai_plugin.rb
Normal file
33
cookbooks/nginx/recipes/ohai_plugin.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipe:: ohai_plugin
|
||||
#
|
||||
# Author:: Jamie Winsor (<jamie@vialstudios.com>)
|
||||
#
|
||||
# Copyright:: 2012-2017, Riot Games
|
||||
# Copyright:: 2016-2017, 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.
|
||||
#
|
||||
|
||||
# for notification post install / change
|
||||
ohai 'reload_nginx' do
|
||||
plugin 'nginx'
|
||||
action :nothing
|
||||
end
|
||||
|
||||
ohai_plugin 'nginx' do
|
||||
source_file 'plugins/ohai-nginx.rb.erb'
|
||||
variables binary: node['nginx']['binary']
|
||||
resource :template
|
||||
end
|
||||
42
cookbooks/nginx/recipes/openssl_source.rb
Normal file
42
cookbooks/nginx/recipes/openssl_source.rb
Normal file
@@ -0,0 +1,42 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipe:: openssl_source
|
||||
#
|
||||
# Author:: David Radcliffe (<radcliffe.david@gmail.com>)
|
||||
#
|
||||
# Copyright:: 2013-2017, 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']
|
||||
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}"]
|
||||
57
cookbooks/nginx/recipes/package.rb
Normal file
57
cookbooks/nginx/recipes/package.rb
Normal file
@@ -0,0 +1,57 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipe:: package
|
||||
# Author:: AJ Christensen <aj@junglist.gen.nz>
|
||||
#
|
||||
# Copyright:: 2008-2017, 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 node['nginx']['ohai_plugin_enabled']
|
||||
|
||||
case node['nginx']['repo_source']
|
||||
when 'epel'
|
||||
if platform_family?('rhel')
|
||||
include_recipe 'yum-epel'
|
||||
else
|
||||
Chef::Log.warn("node['nginx']['repo_source'] set to EPEL, but not running on a RHEL platform so skipping EPEL setup")
|
||||
end
|
||||
when 'nginx'
|
||||
include_recipe 'nginx::repo'
|
||||
package_install_opts = '--disablerepo=* --enablerepo=nginx' if platform_family?('rhel')
|
||||
when 'passenger'
|
||||
if platform_family?('debian')
|
||||
include_recipe 'nginx::repo_passenger'
|
||||
else
|
||||
Chef::Log.warn("node['nginx']['repo_source'] set to passenger, but not running on a Debian based platform so skipping repo setup")
|
||||
end
|
||||
else
|
||||
Chef::Log.warn('Unrecognized distro value set, or no value set. Using distro provided packages instead.')
|
||||
end
|
||||
|
||||
package node['nginx']['package_name'] do
|
||||
options package_install_opts
|
||||
notifies :reload, 'ohai[reload_nginx]', :immediately if node['nginx']['ohai_plugin_enabled']
|
||||
end
|
||||
|
||||
include_recipe 'nginx::commons'
|
||||
|
||||
if node['nginx']['repo_source'] == 'passenger'
|
||||
include_recipe 'nginx::passenger'
|
||||
end
|
||||
|
||||
service 'nginx' do
|
||||
supports status: true, restart: true, reload: true
|
||||
action [:start, :enable]
|
||||
end
|
||||
52
cookbooks/nginx/recipes/pagespeed_module.rb
Normal file
52
cookbooks/nginx/recipes/pagespeed_module.rb
Normal file
@@ -0,0 +1,52 @@
|
||||
#
|
||||
# Cookbook:: 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']
|
||||
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']
|
||||
not_if { ::File.exist?(psol_src_filepath) }
|
||||
end
|
||||
|
||||
package_array = value_for_platform_family(
|
||||
%w(rhel amazon) => node['nginx']['pagespeed']['packages']['rhel'],
|
||||
%w(debian) => node['nginx']['pagespeed']['packages']['debian']
|
||||
)
|
||||
|
||||
package package_array unless package_array.empty?
|
||||
|
||||
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}"]
|
||||
57
cookbooks/nginx/recipes/passenger.rb
Normal file
57
cookbooks/nginx/recipes/passenger.rb
Normal file
@@ -0,0 +1,57 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipe:: Passenger
|
||||
#
|
||||
# Copyright:: 2013-2017, 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 amazon) => node['nginx']['passenger']['packages']['rhel'],
|
||||
%w(fedora) => node['nginx']['passenger']['packages']['fedora'],
|
||||
%w(debian) => node['nginx']['passenger']['packages']['debian']
|
||||
)
|
||||
|
||||
package packages unless packages.empty?
|
||||
|
||||
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
|
||||
|
||||
passenger_module = node['nginx']['passenger']['root']
|
||||
|
||||
passenger_module += if Chef::VersionConstraint.new('>= 5.0.19').include?(node['nginx']['passenger']['version'])
|
||||
'/src/nginx_module'
|
||||
else
|
||||
'/ext/nginx'
|
||||
end
|
||||
|
||||
node.run_state['nginx_configure_flags'] =
|
||||
node.run_state['nginx_configure_flags'] | ["--add-module=#{passenger_module}"]
|
||||
|
||||
end
|
||||
|
||||
template node['nginx']['passenger']['conf_file'] do
|
||||
source 'modules/passenger.conf.erb'
|
||||
notifies :reload, 'service[nginx]', :delayed
|
||||
end
|
||||
53
cookbooks/nginx/recipes/repo.rb
Normal file
53
cookbooks/nginx/recipes/repo.rb
Normal file
@@ -0,0 +1,53 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipe:: repo
|
||||
# Author:: Nick Rycar <nrycar@bluebox.net>
|
||||
#
|
||||
# Copyright:: 2008-2017, 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', 'amazon'
|
||||
|
||||
yum_repository 'nginx' do
|
||||
description 'Nginx.org Repository'
|
||||
baseurl node['nginx']['upstream_repository']
|
||||
gpgkey node['nginx']['repo_signing_key']
|
||||
action :create
|
||||
end
|
||||
|
||||
when 'suse'
|
||||
|
||||
zypper_repo 'nginx' do
|
||||
repo_name 'Nginx.org Repository'
|
||||
uri node['nginx']['upstream_repository']
|
||||
key node['nginx']['repo_signing_key']
|
||||
end
|
||||
|
||||
when 'debian'
|
||||
|
||||
apt_repository 'nginx' do
|
||||
uri node['nginx']['upstream_repository']
|
||||
distribution node['lsb']['codename']
|
||||
components %w(nginx)
|
||||
deb_src true
|
||||
key node['nginx']['repo_signing_key']
|
||||
end
|
||||
|
||||
else
|
||||
log "nginx.org does not maintain packages for platform #{node['platform']}. Cannot setup the upstream repo!" do
|
||||
level :warn
|
||||
end
|
||||
end
|
||||
34
cookbooks/nginx/recipes/repo_passenger.rb
Normal file
34
cookbooks/nginx/recipes/repo_passenger.rb
Normal file
@@ -0,0 +1,34 @@
|
||||
# Cookbook:: 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.
|
||||
#
|
||||
|
||||
if platform_family?('debian')
|
||||
package 'ca-certificates'
|
||||
|
||||
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
|
||||
else
|
||||
log "There is not official phusion passenger repo platform #{node['platform']}. Skipping repo setup!" do
|
||||
level :warn
|
||||
end
|
||||
end
|
||||
|
||||
27
cookbooks/nginx/recipes/set_misc.rb
Normal file
27
cookbooks/nginx/recipes/set_misc.rb
Normal file
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# Cookbook:: 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']
|
||||
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'
|
||||
23
cookbooks/nginx/recipes/socketproxy.rb
Normal file
23
cookbooks/nginx/recipes/socketproxy.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
include_recipe 'nginx::commons_dir'
|
||||
|
||||
directory node['nginx']['socketproxy']['root'] do
|
||||
owner node['nginx']['socketproxy']['app_owner']
|
||||
group node['nginx']['socketproxy']['app_owner']
|
||||
mode '0755'
|
||||
action :create
|
||||
end
|
||||
|
||||
context_names = node['nginx']['socketproxy']['apps'].map do |_app, app_conf|
|
||||
app_conf['context_name']
|
||||
end
|
||||
|
||||
raise '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'
|
||||
notifies :reload, 'service[nginx]', :delayed
|
||||
end
|
||||
|
||||
link node['nginx']['dir'] + '/sites-enabled/socketproxy.conf' do
|
||||
to node['nginx']['dir'] + '/sites-available/socketproxy.conf'
|
||||
end
|
||||
173
cookbooks/nginx/recipes/source.rb
Normal file
173
cookbooks/nginx/recipes/source.rb
Normal file
@@ -0,0 +1,173 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipe:: source
|
||||
#
|
||||
# Author:: Adam Jacob (<adam@chef.io>)
|
||||
# Author:: Joshua Timberman (<joshua@chef.io>)
|
||||
# Author:: Jamie Winsor (<jamie@vialstudios.com>)
|
||||
#
|
||||
# Copyright:: 2009-2017, 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.
|
||||
#
|
||||
|
||||
raise "#{node['platform']} is not a supported platform in the nginx::source recipe" unless platform_family?('rhel', 'amazon', 'fedora', 'debian', 'suse')
|
||||
|
||||
node.normal['nginx']['binary'] = node['nginx']['source']['sbin_path']
|
||||
node.normal['nginx']['daemon_disable'] = true
|
||||
|
||||
user node['nginx']['user'] do
|
||||
system true
|
||||
shell '/bin/false'
|
||||
home node['nginx']['user_home']
|
||||
manage_home true
|
||||
not_if { node['nginx']['source']['use_existing_user'] }
|
||||
end
|
||||
|
||||
include_recipe 'nginx::ohai_plugin' if node['nginx']['ohai_plugin_enabled']
|
||||
include_recipe 'nginx::commons_dir'
|
||||
include_recipe 'nginx::commons_script'
|
||||
build_essential 'install compilation tools'
|
||||
|
||||
src_filepath = "#{Chef::Config['file_cache_path']}/nginx-#{node['nginx']['source']['version']}.tar.gz"
|
||||
|
||||
# install prereqs
|
||||
package value_for_platform_family(
|
||||
%w(rhel fedora amazon) => %w(pcre-devel openssl-devel tar zlib-devel),
|
||||
%w(suse) => %w(pcre-devel libopenssl-devel tar),
|
||||
%w(debian) => %w(libpcre3 libpcre3-dev libssl-dev tar zlib1g-dev)
|
||||
)
|
||||
|
||||
remote_file 'nginx source' do
|
||||
source node['nginx']['source']['url']
|
||||
checksum node['nginx']['source']['checksum']
|
||||
path src_filepath
|
||||
backup false
|
||||
retries 4
|
||||
end
|
||||
|
||||
node.run_state['nginx_force_recompile'] = false
|
||||
node.run_state['nginx_configure_flags'] =
|
||||
node['nginx']['source']['default_configure_flags'] | node['nginx']['configure_flags']
|
||||
node.run_state['nginx_source_env'] = {}
|
||||
|
||||
include_recipe 'nginx::commons_conf'
|
||||
|
||||
cookbook_file "#{node['nginx']['dir']}/mime.types" do
|
||||
source 'mime.types'
|
||||
notifies :reload, 'service[nginx]', :delayed
|
||||
end
|
||||
|
||||
# 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)} --no-same-owner
|
||||
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)
|
||||
environment node.run_state['nginx_source_env']
|
||||
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 if node['nginx']['ohai_plugin_enabled']
|
||||
end
|
||||
|
||||
case node['nginx']['init_style']
|
||||
when 'upstart'
|
||||
# we rely on this to set up nginx.conf with daemon disable instead of doing
|
||||
# it in the upstart init script.
|
||||
node.normal['nginx']['daemon_disable'] = node['nginx']['upstart']['foreground']
|
||||
|
||||
template '/etc/init/nginx.conf' do
|
||||
source 'nginx-upstart.conf.erb'
|
||||
variables(lazy { { pid_file: pidfile_location } })
|
||||
end
|
||||
|
||||
service 'nginx' do
|
||||
provider Chef::Provider::Service::Upstart
|
||||
supports status: true, restart: true, reload: true
|
||||
action [:start, :enable]
|
||||
end
|
||||
when 'systemd'
|
||||
|
||||
systemd_prefix = platform_family?('suse') ? '/usr/lib' : '/lib'
|
||||
|
||||
template "#{systemd_prefix}/systemd/system/nginx.service" do
|
||||
source 'nginx.service.erb'
|
||||
end
|
||||
|
||||
service 'nginx' do
|
||||
provider Chef::Provider::Service::Systemd
|
||||
supports status: true, restart: true, reload: true
|
||||
action [:start, :enable]
|
||||
end
|
||||
else
|
||||
node.normal['nginx']['daemon_disable'] = false
|
||||
|
||||
generate_init = true
|
||||
|
||||
case node['platform']
|
||||
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'
|
||||
mode '0755'
|
||||
variables(lazy { { pid_file: pidfile_location } })
|
||||
end if generate_init
|
||||
|
||||
if generate_template # ~FC023
|
||||
template defaults_path do
|
||||
source 'nginx.sysconfig.erb'
|
||||
end
|
||||
end
|
||||
|
||||
service 'nginx' do
|
||||
supports status: true, restart: true, reload: true
|
||||
action [:start, :enable]
|
||||
end
|
||||
end
|
||||
|
||||
node.run_state.delete('nginx_configure_flags')
|
||||
node.run_state.delete('nginx_force_recompile')
|
||||
67
cookbooks/nginx/recipes/syslog_module.rb
Normal file
67
cookbooks/nginx/recipes/syslog_module.rb
Normal file
@@ -0,0 +1,67 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipe:: syslog_module
|
||||
#
|
||||
# Author:: Bob Ziuchkovski (<bob@bz-technology.com>)
|
||||
#
|
||||
# Copyright:: 2014-2017, 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) }
|
||||
raise 'Unsupported nginx version' if major != 1
|
||||
case minor
|
||||
when 2
|
||||
syslog_patch = case patch
|
||||
when 0..6
|
||||
'syslog_1.2.0.patch'
|
||||
else
|
||||
'syslog_1.2.7.patch'
|
||||
end
|
||||
when 3
|
||||
syslog_patch = case patch
|
||||
when 0..9
|
||||
'syslog_1.2.0.patch'
|
||||
when 10..13
|
||||
'syslog_1.3.11.patch'
|
||||
else
|
||||
'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
|
||||
raise 'Unsupported nginx version'
|
||||
end
|
||||
|
||||
git nginx_syslog_src do
|
||||
repository node['nginx']['syslog']['git_repo']
|
||||
revision node['nginx']['syslog']['git_revision']
|
||||
action :sync
|
||||
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}"]
|
||||
47
cookbooks/nginx/recipes/upload_progress_module.rb
Normal file
47
cookbooks/nginx/recipes/upload_progress_module.rb
Normal file
@@ -0,0 +1,47 @@
|
||||
#
|
||||
# Cookbook:: nginx
|
||||
# Recipe:: upload_progress_module
|
||||
#
|
||||
# Author:: Jamie Winsor (<jamie@vialstudios.com>)
|
||||
#
|
||||
# Copyright:: 2012-2017, 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']
|
||||
end
|
||||
|
||||
template "#{node['nginx']['dir']}/conf.d/upload_progress.conf" do
|
||||
source 'modules/upload_progress.erb'
|
||||
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}"]
|
||||
Reference in New Issue
Block a user