Permalink
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...
Eric G. Wolfe
Eric G. Wolfe committed May 23, 2012
1 parent c8093ee commit 55305804379376474567841af5545b3bbd110248
View
@@ -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
@@ -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
@@ -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
@@ -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"
]
@@ -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
@@ -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
Binary file not shown.
View
@@ -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
@@ -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"
@@ -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'"]
@@ -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"]
@@ -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"]
@@ -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"]
@@ -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
@@ -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']
)
Oops, something went wrong.

0 comments on commit 5530580

Please sign in to comment.