Commit baae975d7e1c0153fd712c7cdd189aace595a634
Committed by
Earth Ugat

1 parent
b17c192a
Bump to v0.4.4. Add more customization to Nginx templates.
Showing
4 changed files
with
39 additions
and
27 deletions
1 | +## 0.4.4 - 2016-11-09 | ||
2 | +### Added | ||
3 | +- Nginx recipe: Add template file customization for the main site config and for all site types. | ||
4 | + | ||
1 | ## 0.4.3 - 2016-10-06 | 5 | ## 0.4.3 - 2016-10-06 |
2 | ### Fixed | 6 | ### Fixed |
3 | - Missing ssl key and cert clauses in the "catch_all" blocks in the nginx config causes an error during SSL handshake if HTTPS is used. | 7 | - Missing ssl key and cert clauses in the "catch_all" blocks in the nginx config causes an error during SSL handshake if HTTPS is used. |
@@ -146,6 +146,12 @@ default['cfe-nginx-php-fpm']['nginx']['sites'] = [ | @@ -146,6 +146,12 @@ default['cfe-nginx-php-fpm']['nginx']['sites'] = [ | ||
146 | # | 146 | # |
147 | #:server_statements_2 => [], | 147 | #:server_statements_2 => [], |
148 | 148 | ||
149 | + # The cookbook name and source file where the main | ||
150 | + # config file template will be taken from. | ||
151 | + # | ||
152 | + #:main_config_cookbook => 'cfe-nginx-php-fpm', | ||
153 | + #:main_config_source => 'nginx_site.conf.erb', | ||
154 | + | ||
149 | # Enumerates the different site types this server supports. | 155 | # Enumerates the different site types this server supports. |
150 | # Each type element of this array is a hash containing different attributes. | 156 | # Each type element of this array is a hash containing different attributes. |
151 | # | 157 | # |
@@ -179,6 +185,14 @@ default['cfe-nginx-php-fpm']['nginx']['sites'] = [ | @@ -179,6 +185,14 @@ default['cfe-nginx-php-fpm']['nginx']['sites'] = [ | ||
179 | # } | 185 | # } |
180 | # :log_static => Whether to log accesses to the above static files | 186 | # :log_static => Whether to log accesses to the above static files |
181 | # or not. Default: false | 187 | # or not. Default: false |
188 | + # :source => The name of the config template. | ||
189 | + # Default depends on :type attribute. | ||
190 | + # :cookbook => The name of the cookbook where the template | ||
191 | + # will be taken from. Default is this cookbook. | ||
192 | + # :custom_params => A hash that will be passed into the template | ||
193 | + # (along with the optional attributes mentioned | ||
194 | + # above) as the variable called cparams. | ||
195 | + # Default: {} | ||
182 | # | 196 | # |
183 | # Unique attributes for each type are indicated below: | 197 | # Unique attributes for each type are indicated below: |
184 | # Basic PHP Site (:type => 'basic_php'): | 198 | # Basic PHP Site (:type => 'basic_php'): |
@@ -191,18 +205,7 @@ default['cfe-nginx-php-fpm']['nginx']['sites'] = [ | @@ -191,18 +205,7 @@ default['cfe-nginx-php-fpm']['nginx']['sites'] = [ | ||
191 | # Proxy Websocket Webserver (:type => 'webserver_ws'): | 205 | # Proxy Websocket Webserver (:type => 'webserver_ws'): |
192 | # (none) | 206 | # (none) |
193 | # Proxy Generic Webserver (:type => 'webserver_basic'): | 207 | # Proxy Generic Webserver (:type => 'webserver_basic'): |
194 | - # :source => The name of the config template. | ||
195 | - # Default is 'inc_type_webserver_basic.erb'. | ||
196 | - # :cookbook => The name of the cookbook where the template | ||
197 | - # will be taken from. Default is this cookbook. | ||
198 | - # In combination with the :source attribute above, | ||
199 | - # any custom template in a wrapper cookbook can be | ||
200 | - # used. A template file 'inc_type_webserver_basic.erb' | ||
201 | - # exists as an example. | ||
202 | - # :custom_params => A hash that will be passed into the template | ||
203 | - # (along with the optional attributes mentioned | ||
204 | - # above) as the variable called cparams. | ||
205 | - # Default: {} | 208 | + # (none) |
206 | # | 209 | # |
207 | #:types => [] | 210 | #:types => [] |
208 | #} | 211 | #} |
@@ -4,7 +4,7 @@ maintainer_email 'sysadmin@chromedia.com' | @@ -4,7 +4,7 @@ maintainer_email 'sysadmin@chromedia.com' | ||
4 | license 'Apache License' | 4 | license 'Apache License' |
5 | description 'Simplifies setup of Nginx+PHP-FPM in Chromedia.' | 5 | description 'Simplifies setup of Nginx+PHP-FPM in Chromedia.' |
6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) | 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) |
7 | -version '0.4.3' | 7 | +version '0.4.4' |
8 | 8 | ||
9 | { | 9 | { |
10 | 'openssl' => '4.4.0', | 10 | 'openssl' => '4.4.0', |
@@ -65,6 +65,8 @@ node[cb]['nginx']['sites'].each do |site| | @@ -65,6 +65,8 @@ node[cb]['nginx']['sites'].each do |site| | ||
65 | site_ins = site[:init_statements] || [] | 65 | site_ins = site[:init_statements] || [] |
66 | site_ss1 = site[:server_statements_1] || [] | 66 | site_ss1 = site[:server_statements_1] || [] |
67 | site_ss2 = site[:server_statements_2] || [] | 67 | site_ss2 = site[:server_statements_2] || [] |
68 | + site_cb = site[:main_config_cookbook] || cb | ||
69 | + site_source = site[:main_config_source] || 'nginx_site.conf.erb' | ||
68 | 70 | ||
69 | site_bl_robots = site.has_key?(:block_robots) ? site[:block_robots] : true | 71 | site_bl_robots = site.has_key?(:block_robots) ? site[:block_robots] : true |
70 | site_bl_fav = site.has_key?(:block_fav) ? site[:block_fav] : true | 72 | site_bl_fav = site.has_key?(:block_fav) ? site[:block_fav] : true |
@@ -82,9 +84,9 @@ node[cb]['nginx']['sites'].each do |site| | @@ -82,9 +84,9 @@ node[cb]['nginx']['sites'].each do |site| | ||
82 | 'X-Permitted-Cross-Domain-Policies' => 'none' | 84 | 'X-Permitted-Cross-Domain-Policies' => 'none' |
83 | } | 85 | } |
84 | 86 | ||
85 | - path_crt = '' | ||
86 | - path_key = '' | ||
87 | - path_pass = '' | 87 | + path_crt = '' |
88 | + path_key = '' | ||
89 | + path_pass = '' | ||
88 | 90 | ||
89 | # If TLS/SSL is enabled, configure it: | 91 | # If TLS/SSL is enabled, configure it: |
90 | if site_ssl | 92 | if site_ssl |
@@ -176,7 +178,8 @@ node[cb]['nginx']['sites'].each do |site| | @@ -176,7 +178,8 @@ node[cb]['nginx']['sites'].each do |site| | ||
176 | :upstream_name => stype_ups, | 178 | :upstream_name => stype_ups, |
177 | :add_statements => stype_ads, | 179 | :add_statements => stype_ads, |
178 | :static_types => stype_statics, | 180 | :static_types => stype_statics, |
179 | - :log_static => stype_logstatic | 181 | + :log_static => stype_logstatic, |
182 | + :cparams => stype[:custom_params] || {} | ||
180 | } | 183 | } |
181 | 184 | ||
182 | if stype[:upstream_servers] && stype[:upstream_servers].length > 0 | 185 | if stype[:upstream_servers] && stype[:upstream_servers].length > 0 |
@@ -195,8 +198,9 @@ node[cb]['nginx']['sites'].each do |site| | @@ -195,8 +198,9 @@ node[cb]['nginx']['sites'].each do |site| | ||
195 | stype[:fastcgi_intercept_errors] : false | 198 | stype[:fastcgi_intercept_errors] : false |
196 | 199 | ||
197 | template "#{inc_dir}/type_basic_php_#{site_sname}" do | 200 | template "#{inc_dir}/type_basic_php_#{site_sname}" do |
198 | - source 'inc_type_basic.erb' | ||
199 | - mode 0644 | 201 | + source stype[:source] || 'inc_type_basic.erb' |
202 | + cookbook stype[:cookbook] || cb | ||
203 | + mode 0644 | ||
200 | variables vars | 204 | variables vars |
201 | end | 205 | end |
202 | site_includes.push("#{inc_dir}/type_basic_php_#{site_sname}") | 206 | site_includes.push("#{inc_dir}/type_basic_php_#{site_sname}") |
@@ -210,8 +214,9 @@ node[cb]['nginx']['sites'].each do |site| | @@ -210,8 +214,9 @@ node[cb]['nginx']['sites'].each do |site| | ||
210 | stype[:fastcgi_intercept_errors] : false | 214 | stype[:fastcgi_intercept_errors] : false |
211 | 215 | ||
212 | template "#{inc_dir}/inc_type_wordpress_#{site_sname}" do | 216 | template "#{inc_dir}/inc_type_wordpress_#{site_sname}" do |
213 | - source 'inc_type_wordpress.erb' | ||
214 | - mode 0644 | 217 | + source stype[:source] || 'inc_type_wordpress.erb' |
218 | + cookbook stype[:cookbook] || cb | ||
219 | + mode 0644 | ||
215 | variables vars | 220 | variables vars |
216 | end | 221 | end |
217 | site_includes.push("#{inc_dir}/inc_type_wordpress_#{site_sname}") | 222 | site_includes.push("#{inc_dir}/inc_type_wordpress_#{site_sname}") |
@@ -219,8 +224,9 @@ node[cb]['nginx']['sites'].each do |site| | @@ -219,8 +224,9 @@ node[cb]['nginx']['sites'].each do |site| | ||
219 | # REVERSE PROXY WEBSERVER WITH WEBSOCKET | 224 | # REVERSE PROXY WEBSERVER WITH WEBSOCKET |
220 | when 'webserver', 'webserver_ws' | 225 | when 'webserver', 'webserver_ws' |
221 | template "#{inc_dir}/inc_type_webserver_ws_#{site_sname}" do | 226 | template "#{inc_dir}/inc_type_webserver_ws_#{site_sname}" do |
222 | - source 'inc_type_webserver.erb' | ||
223 | - mode 0644 | 227 | + source stype[:source] || 'inc_type_webserver.erb' |
228 | + cookbook stype[:cookbook] || cb | ||
229 | + mode 0644 | ||
224 | variables vars | 230 | variables vars |
225 | end | 231 | end |
226 | site_ins.push("map $http_upgrade $connection_upgrade {\n"\ | 232 | site_ins.push("map $http_upgrade $connection_upgrade {\n"\ |
@@ -231,11 +237,9 @@ node[cb]['nginx']['sites'].each do |site| | @@ -231,11 +237,9 @@ node[cb]['nginx']['sites'].each do |site| | ||
231 | 237 | ||
232 | # GENERIC REVERSE PROXY WEBSERVER | 238 | # GENERIC REVERSE PROXY WEBSERVER |
233 | when 'webserver_basic' | 239 | when 'webserver_basic' |
234 | - vars[:cparams] = stype[:custom_params] || {} | ||
235 | - | ||
236 | template "#{inc_dir}/inc_type_webserver_basic_#{site_sname}" do | 240 | template "#{inc_dir}/inc_type_webserver_basic_#{site_sname}" do |
237 | source stype[:source] || 'inc_type_webserver_basic.erb' | 241 | source stype[:source] || 'inc_type_webserver_basic.erb' |
238 | - cookbook stype[:cookbook] || cookbook_name | 242 | + cookbook stype[:cookbook] || cb |
239 | mode 0644 | 243 | mode 0644 |
240 | variables vars | 244 | variables vars |
241 | end | 245 | end |
@@ -249,7 +253,8 @@ node[cb]['nginx']['sites'].each do |site| | @@ -249,7 +253,8 @@ node[cb]['nginx']['sites'].each do |site| | ||
249 | 253 | ||
250 | # Create the main config file for this site | 254 | # Create the main config file for this site |
251 | template "#{node['nginx']['dir']}/sites-available/#{site_sname}" do | 255 | template "#{node['nginx']['dir']}/sites-available/#{site_sname}" do |
252 | - source 'nginx_site.conf.erb' | 256 | + source site_source |
257 | + cookbook site_cb | ||
253 | mode 0644 | 258 | mode 0644 |
254 | notifies :restart, 'service[nginx]', :delayed | 259 | notifies :restart, 'service[nginx]', :delayed |
255 | variables( | 260 | variables( |