Skip to content
Browse files

* Change symbols to strings for *foodcritic*

* Remove unnecessary include_attribute "nginx", already in the same attribute scope
* Convert definition to compatible LWRP for *foodcritic*
  • Loading branch information...
1 parent c8093ee commit 55305804379376474567841af5545b3bbd110248 @atomic-penguin atomic-penguin committed May 23, 2012
View
3 CHANGELOG.md
@@ -6,6 +6,9 @@
* Add redhat family platforms to supported OS list
* Update README to note nginx is availabe only by EPEL on redhat platform
* Remove template notify for non-existent ohai[custom_plugins] resource, and move `include_recipe "ohai"` a general fix for all platforms.
+* Change symbols to strings for *foodcritic*
+* Remove unnecessary include_attribute "nginx", already in the same attribute scope
+* Convert definition to compatible LWRP for *foodcritic*
## v0.101.2:
View
12 attributes/default.rb
@@ -21,25 +21,19 @@
#
default['nginx']['version'] = "1.0.14"
+default['nginx']['dir'] = "/etc/nginx"
+default['nginx']['log_dir'] = "/var/log/nginx"
+default['nginx']['binary'] = "/usr/sbin/nginx"
case node['platform']
when "debian","ubuntu"
- default['nginx']['dir'] = "/etc/nginx"
- default['nginx']['log_dir'] = "/var/log/nginx"
default['nginx']['user'] = "www-data"
- default['nginx']['binary'] = "/usr/sbin/nginx"
default['nginx']['init_style'] = "runit"
when "redhat","centos","scientific","amazon","oracle","fedora"
- default['nginx']['dir'] = "/etc/nginx"
- default['nginx']['log_dir'] = "/var/log/nginx"
default['nginx']['user'] = "nginx"
- default['nginx']['binary'] = "/usr/sbin/nginx"
default['nginx']['init_style'] = "init"
else
- default['nginx']['dir'] = "/etc/nginx"
- default['nginx']['log_dir'] = "/var/log/nginx"
default['nginx']['user'] = "www-data"
- default['nginx']['binary'] = "/usr/sbin/nginx"
default['nginx']['init_style'] = "init"
end
View
18 attributes/geoip.rb
@@ -19,12 +19,12 @@
# limitations under the License.
#
-default[:nginx][:geoip][:path] = "/srv/geoip"
-default[:nginx][:geoip][:enable_city] = true
-default[:nginx][:geoip][:country_dat_url] = "http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz"
-default[:nginx][:geoip][:country_dat_checksum] = "a8c1ffeea5edae7e89150f83029a71bb"
-default[:nginx][:geoip][:city_dat_url] = "http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz"
-default[:nginx][:geoip][:city_dat_checksum] = "1075c5dcd106d937c29879330713b8e5"
-default[:nginx][:geoip][:lib_version] = "1.4.8"
-default[:nginx][:geoip][:lib_url] = "http://geolite.maxmind.com/download/geoip/api/c/GeoIP-#{node[:nginx][:geoip][:lib_version]}.tar.gz"
-default[:nginx][:geoip][:lib_checksum] = "05b7300435336231b556df5ab36f326d"
+default['nginx']['geoip']['path'] = "/srv/geoip"
+default['nginx']['geoip']['enable_city'] = true
+default['nginx']['geoip']['country_dat_url'] = "http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz"
+default['nginx']['geoip']['country_dat_checksum'] = "a8c1ffeea5edae7e89150f83029a71bb"
+default['nginx']['geoip']['city_dat_url'] = "http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz"
+default['nginx']['geoip']['city_dat_checksum'] = "1075c5dcd106d937c29879330713b8e5"
+default['nginx']['geoip']['lib_version'] = "1.4.8"
+default['nginx']['geoip']['lib_url'] = "http://geolite.maxmind.com/download/geoip/api/c/GeoIP-#{node['nginx']['geoip']['lib_version']}.tar.gz"
+default['nginx']['geoip']['lib_checksum'] = "05b7300435336231b556df5ab36f326d"
View
17 attributes/source.rb
@@ -18,18 +18,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-include_attribute "nginx"
-set[:nginx][:source][:prefix] = "/opt/nginx-#{node[:nginx][:version]}"
-set[:nginx][:source][:conf_path] = "#{node[:nginx][:dir]}/nginx.conf"
-set[:nginx][:source][:default_configure_flags] = [
- "--prefix=#{node[:nginx][:source][:prefix]}",
- "--conf-path=#{node[:nginx][:dir]}/nginx.conf"
+set['nginx']['source']['prefix'] = "/opt/nginx-#{node['nginx']['version']}"
+set['nginx']['source']['conf_path'] = "#{node['nginx']['dir']}/nginx.conf"
+set['nginx']['source']['default_configure_flags'] = [
+ "--prefix=#{node['nginx']['source']['prefix']}",
+ "--conf-path=#{node['nginx']['dir']}/nginx.conf"
]
-default[:nginx][:configure_flags] = Array.new
-default[:nginx][:source][:url] = "http://nginx.org/download/nginx-#{node[:nginx][:version]}.tar.gz"
-default[:nginx][:source][:modules] = [
+default['nginx']['configure_flags'] = Array.new
+default['nginx']['source']['url'] = "http://nginx.org/download/nginx-#{node['nginx']['version']}.tar.gz"
+default['nginx']['source']['modules'] = [
"http_ssl_module",
"http_gzip_static_module"
]
View
4 attributes/upload_progress.rb
@@ -19,5 +19,5 @@
# limitations under the License.
#
-default[:nginx][:upload_progress][:url] = "https://github.com/masterzen/nginx-upload-progress-module/tarball/v0.8.4"
-default[:nginx][:upload_progress][:checksum] = "9a6acb984d81f5d7e04214d63ae94273"
+default['nginx']['upload_progress']['url'] = "https://github.com/masterzen/nginx-upload-progress-module/tarball/v0.8.4"
+default['nginx']['upload_progress']['checksum'] = "9a6acb984d81f5d7e04214d63ae94273"
View
37 providers/site.rb
@@ -0,0 +1,37 @@
+#
+# Cookbook Name:: nginx
+# Definition:: nginx_site
+# Author:: AJ Christensen <aj@junglist.gen.nz>
+#
+# Copyright 2008-2009, Opscode, 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.
+#
+
+action :enable do
+ execute "nxensite #{new_resource.name}" do
+ command "/usr/sbin/nxensite #{new_resource.name}"
+ notifies :reload, resources(:service => "nginx")
+ not_if do ::File.symlink?("#{node['nginx']['dir']}/sites-enabled/#{new_resource.name}") end
+ end
+ new_resource.updated_by_last_action(true)
+end
+
+action :disable do
+ execute "nxensite #{new_resource.name}" do
+ command "/usr/sbin/nxdissite #{new_resource.name}"
+ notifies :reload, resources(:service => "nginx")
+ only_if do ::File.symlink?("#{node['nginx']['dir']}/sites-enabled/#{new_resource.name}") end
+ end
+ new_resource.updated_by_last_action(true)
+end
View
BIN recipes/.ohai_plugin.rb.swp
Binary file not shown.
View
10 recipes/authorized_ips.rb
@@ -19,22 +19,22 @@
# limitations under the License.
#
-node.default[:nginx][:remote_ip_var] = "remote_addr"
-node.default[:nginx][:authorized_ips] = ["127.0.0.1/32"]
+node.default['nginx']['remote_ip_var'] = "remote_addr"
+node.default['nginx']['authorized_ips'] = ["127.0.0.1/32"]
service "nginx" do
supports :status => true, :restart => true, :reload => true
end
template "authorized_ip" do
- path "#{node[:nginx][:dir]}/authorized_ip"
+ path "#{node['nginx']['dir']}/authorized_ip"
source "modules/authorized_ip.erb"
owner "root"
group "root"
mode "0644"
variables(
- :remote_ip_var => node[:nginx][:remote_ip_var],
- :authorized_ips => node[:nginx][:authorized_ips]
+ :remote_ip_var => node['nginx']['remote_ip_var'],
+ :authorized_ips => node['nginx']['authorized_ips']
)
notifies :reload, resources(:service => "nginx")
View
12 recipes/commons.rb
@@ -1,17 +1,17 @@
-directory node[:nginx][:dir] do
+directory node['nginx']['dir'] do
owner "root"
group "root"
mode "0755"
end
-directory node[:nginx][:log_dir] do
+directory node['nginx']['log_dir'] do
mode 0755
- owner node[:nginx][:user]
+ owner node['nginx']['user']
action :create
end
%w(sites-available sites-enabled conf.d).each do |leaf|
- directory File.join(node[:nginx][:dir], leaf) do
+ directory File.join(node['nginx']['dir'], leaf) do
owner "root"
group "root"
mode "0755"
@@ -28,15 +28,15 @@
end
template "nginx.conf" do
- path "#{node[:nginx][:dir]}/nginx.conf"
+ path "#{node['nginx']['dir']}/nginx.conf"
source "nginx.conf.erb"
owner "root"
group "root"
mode "0644"
notifies :reload, 'service[nginx]', :immediately
end
-template "#{node[:nginx][:dir]}/sites-available/default" do
+template "#{node['nginx']['dir']}/sites-available/default" do
source "default-site.erb"
owner "root"
group "root"
View
42 recipes/http_geoip_module.rb
@@ -19,18 +19,18 @@
# 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}"
+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}"
+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]
+ source node['nginx']['geoip']['lib_url']
+ checksum node['nginx']['geoip']['lib_checksum']
owner "root"
group "root"
mode 0644
@@ -40,23 +40,23 @@
cwd ::File.dirname(geolib_filepath)
code <<-EOH
tar xzvf #{geolib_filepath} -C #{::File.dirname(geolib_filepath)}
- cd GeoIP-#{node[:nginx][:geoip][:lib_version]} && ./configure
+ cd GeoIP-#{node['nginx']['geoip']['lib_version']} && ./configure
make && make install
EOH
- creates "/usr/local/lib/libGeoIP.so.#{node[:nginx][:geoip][:lib_version]}"
+ creates "/usr/local/lib/libGeoIP.so.#{node['nginx']['geoip']['lib_version']}"
subscribes :run, resources(:remote_file => geolib_filepath)
end
-directory "#{node[:nginx][:geoip][:path]}" do
+directory node['nginx']['geoip']['path'] do
owner "root"
group "root"
mode 0755
end
remote_file country_src_filepath do
- source node[:nginx][:geoip][:country_dat_url]
- checksum node[:nginx][:geoip][:country_dat_checksum]
+ source node['nginx']['geoip']['country_dat_url']
+ checksum node['nginx']['geoip']['country_dat_checksum']
owner "root"
group "root"
mode 0644
@@ -69,12 +69,12 @@
creates country_dat
end
-if node[:nginx][:geoip][:enable_city]
- city_dat = "#{node[:nginx][:geoip][:path]}/GeoLiteCity.dat"
+if node['nginx']['geoip']['enable_city']
+ city_dat = "#{node['nginx']['geoip']['path']}/GeoLiteCity.dat"
remote_file city_src_filepath do
- source node[:nginx][:geoip][:city_dat_url]
- checksum node[:nginx][:geoip][:city_dat_checksum]
+ source node['nginx']['geoip']['city_dat_url']
+ checksum node['nginx']['geoip']['city_dat_checksum']
owner "root"
group "root"
mode 0644
@@ -88,7 +88,7 @@
end
end
-template "#{node[:nginx][:dir]}/conf.d/http_geoip.conf" do
+template "#{node['nginx']['dir']}/conf.d/http_geoip.conf" do
source "modules/http_geoip.conf.erb"
owner "root"
group "root"
@@ -99,5 +99,5 @@
)
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'"]
+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
4 recipes/http_gzip_static_module.rb
@@ -19,5 +19,5 @@
# limitations under the License.
#
-node.run_state[:nginx_configure_flags] =
- node.run_state[:nginx_configure_flags] | ["--with-http_gzip_static_module"]
+node.run_state['nginx_configure_flags'] =
+ node.run_state['nginx_configure_flags'] | ["--with-http_gzip_static_module"]
View
14 recipes/http_realip_module.rb
@@ -22,25 +22,25 @@
# 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']['header'] = "X-Forwarded-For"
+node.default['nginx']['realip']['addresses'] = ["127.0.0.1"]
service "nginx" do
supports :status => true, :restart => true, :reload => true
end
-template "#{node[:nginx][:dir]}/conf.d/http_realip.conf" do
+template "#{node['nginx']['dir']}/conf.d/http_realip.conf" do
source "modules/http_realip.conf.erb"
owner "root"
group "root"
mode "0644"
variables(
- :addresses => node[:nginx][:realip][:addresses],
- :header => node[:nginx][:realip][:header]
+ :addresses => node['nginx']['realip']['addresses'],
+ :header => node['nginx']['realip']['header']
)
notifies :reload, resources(:service => "nginx")
end
-node.run_state[:nginx_configure_flags] =
- node.run_state[:nginx_configure_flags] | ["--with-http_realip_module"]
+node.run_state['nginx_configure_flags'] =
+ node.run_state['nginx_configure_flags'] | ["--with-http_realip_module"]
View
4 recipes/http_ssl_module.rb
@@ -19,5 +19,5 @@
# limitations under the License.
#
-node.run_state[:nginx_configure_flags] =
- node.run_state[:nginx_configure_flags] | ["--with-http_ssl_module"]
+node.run_state['nginx_configure_flags'] =
+ node.run_state['nginx_configure_flags'] | ["--with-http_ssl_module"]
View
6 recipes/http_stub_status_module.rb
@@ -22,7 +22,7 @@
include_recipe "nginx::authorized_ips"
template "nginx_status" do
- path "#{node[:nginx][:dir]}/sites-available/nginx_status"
+ path "#{node['nginx']['dir']}/sites-available/nginx_status"
source "modules/nginx_status.erb"
owner "root"
group "root"
@@ -32,5 +32,5 @@
nginx_site "nginx_status"
-node.run_state[:nginx_configure_flags] =
- node.run_state[:nginx_configure_flags] | ["--with-http_stub_status_module"]
+node.run_state['nginx_configure_flags'] =
+ node.run_state['nginx_configure_flags'] | ["--with-http_stub_status_module"]
View
7 recipes/ohai_plugin.rb
@@ -20,11 +20,10 @@
#
template "#{node['ohai']['plugin_path']}/nginx.rb" do
- source 'plugins/nginx.rb.erb'
- owner 'root'
- group 'root'
+ source "plugins/nginx.rb.erb"
+ owner "root"
+ group "root"
mode 0755
-
variables(
:nginx_bin => node['nginx']['binary']
)
View
80 recipes/source.rb
@@ -22,28 +22,28 @@
#
-nginx_url = node[:nginx][:source][:url] ||
- "http://nginx.org/download/nginx-#{node[:nginx][:version]}.tar.gz"
+nginx_url = node['nginx']['source']['url'] ||
+ "http://nginx.org/download/nginx-#{node['nginx']['version']}.tar.gz"
-unless(node[:nginx][:source][:prefix])
- node.set[:nginx][:source][:prefix] = "/opt/nginx-#{node[:nginx][:version]}"
+unless(node['nginx']['source']['prefix'])
+ node.set['nginx']['source']['prefix'] = "/opt/nginx-#{node['nginx']['version']}"
end
-unless(node[:nginx][:source][:conf_path])
- node.set[:nginx][:source][:conf_path] = "#{node[:nginx][:dir]}/nginx.conf"
+unless(node['nginx']['source']['conf_path'])
+ node.set['nginx']['source']['conf_path'] = "#{node['nginx']['dir']}/nginx.conf"
end
-unless(node[:nginx][:source][:default_configure_flags])
- node.set[:nginx][:source][:default_configure_flags] = [
- "--prefix=#{node[:nginx][:source][:prefix]}",
- "--conf-path=#{node[:nginx][:dir]}/nginx.conf"
+unless(node['nginx']['source']['default_configure_flags'])
+ node.set['nginx']['source']['default_configure_flags'] = [
+ "--prefix=#{node['nginx']['source']['prefix']}",
+ "--conf-path=#{node['nginx']['dir']}/nginx.conf"
]
end
-node.set[:nginx][:binary] = "#{node[:nginx][:source][:prefix]}/sbin/nginx"
-node.set[:nginx][:daemon_disable] = true
+node.set['nginx']['binary'] = "#{node['nginx']['source']['prefix']}/sbin/nginx"
+node.set['nginx']['daemon_disable'] = true
include_recipe "nginx::ohai_plugin"
include_recipe "build-essential"
-src_filepath = "#{Chef::Config[:file_cache_path] || '/tmp'}/nginx-#{node[:nginx][:version]}.tar.gz"
+src_filepath = "#{Chef::Config['file_cache_path'] || '/tmp'}/nginx-#{node['nginx']['version']}.tar.gz"
packages = value_for_platform(
["centos","redhat","fedora"] => {'default' => ['pcre-devel', 'openssl-devel']},
"default" => ['libpcre3', 'libpcre3-dev', 'libssl-dev']
@@ -59,52 +59,52 @@
backup false
end
-user node[:nginx][:user] do
+user node['nginx']['user'] do
system true
shell "/bin/false"
home "/var/www"
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_force_recompile'] = false
+node.run_state['nginx_configure_flags'] =
+ node['nginx']['source']['default_configure_flags'] | node['nginx']['configure_flags']
-node[:nginx][:source][:modules].each do |ngx_module|
+node['nginx']['source']['modules'].each do |ngx_module|
include_recipe "nginx::#{ngx_module}"
end
-configure_flags = node.run_state[:nginx_configure_flags]
-nginx_force_recompile = node.run_state[:nginx_force_recompile]
+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
tar zxf #{::File.basename(src_filepath)} -C #{::File.dirname(src_filepath)}
- cd nginx-#{node[:nginx][:version]} && ./configure #{node.run_state[:nginx_configure_flags].join(" ")}
+ cd nginx-#{node['nginx']['version']} && ./configure #{node.run_state['nginx_configure_flags'].join(" ")}
make && make install
- rm -f #{node[:nginx][:dir]}/nginx.conf
+ rm -f #{node['nginx']['dir']}/nginx.conf
EOH
not_if do
nginx_force_recompile == false &&
- node.automatic_attrs[:nginx][:version] == node[:nginx][:version] &&
- node.automatic_attrs[:nginx][:configure_arguments].sort == configure_flags.sort
+ node.automatic_attrs['nginx']['version'] == node['nginx']['version'] &&
+ node.automatic_attrs['nginx']['configure_arguments'].sort == configure_flags.sort
end
end
node.run_state.delete(:nginx_configure_flags)
node.run_state.delete(:nginx_force_recompile)
-case node[:nginx][:init_style]
+case node['nginx']['init_style']
when "runit"
- node.set[:nginx][:src_binary] = node[:nginx][:binary]
+ node.set['nginx']['src_binary'] = node['nginx']['binary']
include_recipe "runit"
runit_service "nginx"
service "nginx" do
supports :status => true, :restart => true, :reload => true
- reload_command "[[ -f #{node[:nginx][:pid]} ]] && kill -HUP `cat #{node[:nginx][:pid]}` || true"
+ reload_command "[[ -f #{node['nginx']['pid']} ]] && kill -HUP `cat #{node['nginx']['pid']}` || true"
end
when "bluepill"
include_recipe "bluepill"
@@ -113,11 +113,11 @@
source "nginx.pill.erb"
mode 0644
variables(
- :working_dir => node[:nginx][:source][:prefix],
- :src_binary => node[:nginx][:binary],
- :nginx_dir => node[:nginx][:dir],
- :log_dir => node[:nginx][:log_dir],
- :pid => node[:nginx][:pid]
+ :working_dir => node['nginx']['source']['prefix'],
+ :src_binary => node['nginx']['binary'],
+ :nginx_dir => node['nginx']['dir'],
+ :log_dir => node['nginx']['log_dir'],
+ :pid => node['nginx']['pid']
)
end
@@ -127,23 +127,23 @@
service "nginx" do
supports :status => true, :restart => true, :reload => true
- reload_command "[[ -f #{node[:nginx][:pid]} ]] && kill -HUP `cat #{node[:nginx][:pid]}` || true"
+ reload_command "[[ -f #{node['nginx']['pid']} ]] && kill -HUP `cat #{node['nginx']['pid']}` || true"
action :nothing
end
else
- node.set[:nginx][:daemon_disable] = false
+ node.set['nginx']['daemon_disable'] = false
template "/etc/init.d/nginx" do
source "nginx.init.erb"
owner "root"
group "root"
mode "0755"
variables(
- :working_dir => node[:nginx][:source][:prefix],
- :src_binary => node[:nginx][:binary],
- :nginx_dir => node[:nginx][:dir],
- :log_dir => node[:nginx][:log_dir],
- :pid => node[:nginx][:pid]
+ :working_dir => node['nginx']['source']['prefix'],
+ :src_binary => node['nginx']['binary'],
+ :nginx_dir => node['nginx']['dir'],
+ :log_dir => node['nginx']['log_dir'],
+ :pid => node['nginx']['pid']
)
end
@@ -171,7 +171,7 @@
include_recipe 'nginx::commons'
-cookbook_file "#{node[:nginx][:dir]}/mime.types" do
+cookbook_file "#{node['nginx']['dir']}/mime.types" do
source "mime.types"
owner "root"
group "root"
View
14 recipes/upload_progress_module.rb
@@ -19,13 +19,13 @@
# 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]}"
+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]
+ source node['nginx']['upload_progress']['url']
+ checksum node['nginx']['upload_progress']['checksum']
owner "root"
group "root"
mode 0644
@@ -42,6 +42,6 @@
not_if { ::File.exists?(upm_extract_path) }
end
-node.run_state[:nginx_configure_flags] =
- node.run_state[:nginx_configure_flags] | ["--add-module=#{upm_extract_path}"]
+node.run_state['nginx_configure_flags'] =
+ node.run_state['nginx_configure_flags'] | ["--add-module=#{upm_extract_path}"]
View
21 definitions/nginx_site.rb → resources/site.rb
@@ -18,18 +18,11 @@
# limitations under the License.
#
-define :nginx_site, :enable => true do
- if params[:enable]
- execute "nxensite #{params[:name]}" do
- command "/usr/sbin/nxensite #{params[:name]}"
- notifies :reload, resources(:service => "nginx")
- not_if do ::File.symlink?("#{node[:nginx][:dir]}/sites-enabled/#{params[:name]}") end
- end
- else
- execute "nxdissite #{params[:name]}" do
- command "/usr/sbin/nxdissite #{params[:name]}"
- notifies :reload, resources(:service => "nginx")
- only_if do ::File.symlink?("#{node[:nginx][:dir]}/sites-enabled/#{params[:name]}") end
- end
- end
+def initialize(*args)
+ super
+ @action = :create
end
+
+actions :enable, :disable
+
+attribute :name, :kind_of => String, :name_attribute => true
View
4 templates/default/default-site.erb
@@ -1,8 +1,8 @@
server {
listen 80;
- server_name <%= node[:hostname] %>;
+ server_name <%= node['hostname'] %>;
- access_log <%= node[:nginx][:log_dir] %>/localhost.access.log;
+ access_log <%= node['nginx']['log_dir'] %>/localhost.access.log;
location / {
root /var/www/nginx-default;
View
40 templates/default/nginx.conf.erb
@@ -1,42 +1,42 @@
-user <%= node[:nginx][:user] %>;
-worker_processes <%= node[:nginx][:worker_processes] %>;
-<% if node[:nginx][:daemon_disable] -%>
+user <%= node['nginx']['user'] %>;
+worker_processes <%= node['nginx']['worker_processes'] %>;
+<% if node['nginx']['daemon_disable'] -%>
daemon off;
<% end -%>
-error_log <%= node[:nginx][:log_dir] %>/error.log;
-pid <%= node[:nginx][:pid] %>;
+error_log <%= node['nginx']['log_dir'] %>/error.log;
+pid <%= node['nginx']['pid'] %>;
events {
- worker_connections <%= node[:nginx][:worker_connections] %>;
+ worker_connections <%= node['nginx']['worker_connections'] %>;
}
http {
- include <%= node[:nginx][:dir] %>/mime.types;
+ include <%= node['nginx']['dir'] %>/mime.types;
default_type application/octet-stream;
- <% unless node[:nginx][:disable_access_log] -%>
- access_log <%= node[:nginx][:log_dir] %>/access.log;
+ <% unless node['nginx']['disable_access_log'] -%>
+ access_log <%= node['nginx']['log_dir'] %>/access.log;
<% end %>
sendfile on;
tcp_nopush on;
tcp_nodelay on;
- <% if node[:nginx][:keepalive] == "on" %>
- keepalive_timeout <%= node[:nginx][:keepalive_timeout] %>;
+ <% if node['nginx']['keepalive'] == "on" %>
+ keepalive_timeout <%= node['nginx']['keepalive_timeout'] %>;
<% end %>
- gzip <%= node[:nginx][:gzip] %>;
- <% if node[:nginx][:gzip] == "on" %>
- gzip_http_version <%= node[:nginx][:gzip_http_version] %>;
- gzip_comp_level <%= node[:nginx][:gzip_comp_level] %>;
- gzip_proxied <%= node[:nginx][:gzip_proxied] %>;
- gzip_types <%= node[:nginx][:gzip_types].join(' ') %>;
+ gzip <%= node['nginx']['gzip'] %>;
+ <% if node['nginx']['gzip'] == "on" %>
+ gzip_http_version <%= node['nginx']['gzip_http_version'] %>;
+ gzip_comp_level <%= node['nginx']['gzip_comp_level'] %>;
+ gzip_proxied <%= node['nginx']['gzip_proxied'] %>;
+ gzip_types <%= node['nginx']['gzip_types'].join(' ') %>;
<% end %>
- server_names_hash_bucket_size <%= node[:nginx][:server_names_hash_bucket_size] %>;
+ server_names_hash_bucket_size <%= node['nginx']['server_names_hash_bucket_size'] %>;
- include <%= node[:nginx][:dir] %>/conf.d/*.conf;
- include <%= node[:nginx][:dir] %>/sites-enabled/*;
+ include <%= node['nginx']['dir'] %>/conf.d/*.conf;
+ include <%= node['nginx']['dir'] %>/sites-enabled/*;
}
View
2 templates/default/nginx.sysconfig.erb
@@ -1 +1 @@
-NGINX_GLOBAL=<%= node[:nginx][:global] %>
+NGINX_GLOBAL=<%= node['nginx']['global'] %>
View
2 templates/default/nxdissite.erb
@@ -1,6 +1,6 @@
#!/bin/sh -e
-SYSCONFDIR='<%= node[:nginx][:dir] %>'
+SYSCONFDIR='<%= node['nginx']['dir'] %>'
if [ -z $1 ]; then
echo "Which site would you like to disable?"
View
2 templates/default/nxensite.erb
@@ -1,6 +1,6 @@
#!/bin/sh -e
-SYSCONFDIR='<%= node[:nginx][:dir] %>'
+SYSCONFDIR='<%= node['nginx']['dir'] %>'
if [ -z $1 ]; then
echo "Which site would you like to enable?"
View
2 templates/default/sv-nginx-run.erb
@@ -1,3 +1,3 @@
#!/bin/sh
exec 2>&1
-exec <%= node[:nginx][:src_binary] %> -c <%= node[:nginx][:dir] %>/nginx.conf
+exec <%= node['nginx']['src_binary'] %> -c <%= node['nginx']['dir'] %>/nginx.conf

0 comments on commit 5530580

Please sign in to comment.
Something went wrong with that request. Please try again.