Commit bb2c52620281931055558644062c47332ba74ff8

Authored by nollieheel
Committed by Earth Ugat
1 parent d2a63ab7

Bump to v0.1.2. Fix derived attribute pitfalls.

  1 +# 0.1.2
  2 +
  3 +Fix the derived attribute pitfalls
  4 +
1 # 0.1.1 5 # 0.1.1
2 6
3 Made sure all templates use action :create_if_missing 7 Made sure all templates use action :create_if_missing
@@ -31,13 +31,14 @@ default['cfe-nginx-php-fpm']['postfix']['update_cacert'] = true @@ -31,13 +31,14 @@ default['cfe-nginx-php-fpm']['postfix']['update_cacert'] = true
31 default['cfe-nginx-php-fpm']['postfix']['email_domain'] = 'example.com' 31 default['cfe-nginx-php-fpm']['postfix']['email_domain'] = 'example.com'
32 32
33 # If your php-fpm pool is not named 'www', then delete 33 # If your php-fpm pool is not named 'www', then delete
34 -# the default one 'www' automatically installed by php-fpm 34 +# the default one ('www'), which is automatically installed by php-fpm
35 default['cfe-nginx-php-fpm']['php-fpm']['delete_pool_www'] = true 35 default['cfe-nginx-php-fpm']['php-fpm']['delete_pool_www'] = true
36 36
37 -default['cfe-nginx-php-fpm']['nginx']['inc_dir'] =  
38 - "#{node['nginx']['dir']}/sites-available/include"  
39 -default['cfe-nginx-php-fpm']['nginx']['priv_dir'] =  
40 - "#{node['nginx']['dir']}/private" 37 +# Uncomment to set custom locations
  38 +#default['cfe-nginx-php-fpm']['nginx']['inc_dir'] =
  39 +# "#{node['nginx']['dir']}/sites-available/include"
  40 +#default['cfe-nginx-php-fpm']['nginx']['priv_dir'] =
  41 +# "#{node['nginx']['dir']}/private"
41 42
42 default['cfe-nginx-php-fpm']['nginx']['restriction_file']['log_robots'] = false 43 default['cfe-nginx-php-fpm']['nginx']['restriction_file']['log_robots'] = false
43 default['cfe-nginx-php-fpm']['nginx']['restriction_file']['log_hidden'] = true 44 default['cfe-nginx-php-fpm']['nginx']['restriction_file']['log_hidden'] = true
@@ -107,8 +108,10 @@ default['cfe-nginx-php-fpm']['nginx']['sites'] = [ @@ -107,8 +108,10 @@ default['cfe-nginx-php-fpm']['nginx']['sites'] = [
107 # 108 #
108 # php-fpm cookbook 109 # php-fpm cookbook
109 # 110 #
110 -default['php-fpm']['user'] = node['nginx']['user']  
111 -default['php-fpm']['group'] = node['nginx']['group'] 111 +# PHP-FPM user should be the same as the Nginx user by default.
  112 +# To provide custom values, use override, instead of default.
  113 +#override['php-fpm']['user'] = node['nginx']['user']
  114 +#override['php-fpm']['group'] = node['nginx']['group']
112 115
113 default['php-fpm']['skip_repository_install'] = true 116 default['php-fpm']['skip_repository_install'] = true
114 default['php-fpm']['pools'] = [ 117 default['php-fpm']['pools'] = [
@@ -117,18 +120,19 @@ default['php-fpm']['pools'] = [ @@ -117,18 +120,19 @@ default['php-fpm']['pools'] = [
117 { 120 {
118 :name => 'example_pool', 121 :name => 'example_pool',
119 :enable => true, 122 :enable => true,
120 - :listen => node['cfe-nginx-php-fpm']['php_fastcgi_socket'],  
121 123
122 - :user => node['nginx']['user'],  
123 - :group => node['nginx']['group'], 124 + # Default value is: node['cfe-nginx-php-fpm']['php_fastcgi_socket']
  125 + #:listen => node['cfe-nginx-php-fpm']['php_fastcgi_socket'],
  126 +
  127 + # Default is same as Nginx user and group
  128 + #:user => node['nginx']['user'],
  129 + #:group => node['nginx']['group'],
124 130
125 :max_requests => 500, 131 :max_requests => 500,
126 :max_children => 50, 132 :max_children => 50,
127 133
128 :access_log => false, 134 :access_log => false,
129 :catch_workers_output => 'no', 135 :catch_workers_output => 'no',
130 - #:access_log => true,  
131 - #:catch_workers_output => 'yes',  
132 136
133 :process_manager => value_for_platform( 137 :process_manager => value_for_platform(
134 'ubuntu' => { 138 'ubuntu' => {
@@ -161,12 +165,15 @@ default['mariadb']['install']['version'] = '5.5' @@ -161,12 +165,15 @@ default['mariadb']['install']['version'] = '5.5'
161 # postfix cookbook 165 # postfix cookbook
162 # 166 #
163 default['postfix']['main']['myorigin'] = '$mydomain' 167 default['postfix']['main']['myorigin'] = '$mydomain'
164 -default['postfix']['main']['myhostname'] =  
165 - node['cfe-nginx-php-fpm']['postfix']['email_domain']  
166 -default['postfix']['main']['mydomain'] =  
167 - node['cfe-nginx-php-fpm']['postfix']['email_domain']  
168 default['postfix']['main']['mydestination'] = 168 default['postfix']['main']['mydestination'] =
169 ['localhost.localdomain', 'localhost'] 169 ['localhost.localdomain', 'localhost']
  170 +# Defaults for both myhostname and mydomain is:
  171 +# node['cfe-nginx-php-fpm']['postfix']['email_domain']
  172 +# To provide custom values, use override, instead of default.
  173 +#override['postfix']['main']['myhostname'] =
  174 +# node['cfe-nginx-php-fpm']['postfix']['email_domain']
  175 +#override['postfix']['main']['mydomain'] =
  176 +# node['cfe-nginx-php-fpm']['postfix']['email_domain']
170 177
171 # 178 #
172 # nginx cookbook 179 # nginx cookbook
@@ -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.1.1' 7 +version '0.1.2'
8 8
9 { 9 {
10 'php-fpm' => '0.7.5', 10 'php-fpm' => '0.7.5',
@@ -18,6 +18,17 @@ @@ -18,6 +18,17 @@
18 # limitations under the License. 18 # limitations under the License.
19 # 19 #
20 20
  21 +# Set derived attribute defaults inside recipe
  22 +
  23 +node.default['cfe-nginx-php-fpm']['nginx']['inc_dir'] =
  24 + "#{node['nginx']['dir']}/sites-available/include" unless
  25 + node['cfe-nginx-php-fpm']['nginx']['inc_dir']
  26 +node.default['cfe-nginx-php-fpm']['nginx']['priv_dir'] =
  27 + "#{node['nginx']['dir']}/private" unless
  28 + node['cfe-nginx-php-fpm']['nginx']['priv_dir']
  29 +
  30 +# Begin server configuration
  31 +
21 include_recipe 'nginx' 32 include_recipe 'nginx'
22 33
23 attribs = node['cfe-nginx-php-fpm']['nginx'] 34 attribs = node['cfe-nginx-php-fpm']['nginx']
@@ -18,6 +18,37 @@ @@ -18,6 +18,37 @@
18 # limitations under the License. 18 # limitations under the License.
19 # 19 #
20 20
  21 +def mash_to_hash(mash)
  22 + mash.inject({}) do |acc, (k, v)|
  23 + acc[k] = v.is_a?(Hash) ? mash_to_hash(v) : v
  24 + acc
  25 + end
  26 +end
  27 +
  28 +# Set derived attribute defaults inside recipe
  29 +
  30 +node.default['php-fpm']['user'] = node['nginx']['user']
  31 +node.default['php-fpm']['group'] = node['nginx']['group']
  32 +
  33 +if node['php-fpm']['pools']
  34 + is_hash = node['php-fpm']['pools'].is_a?(Hash) # either Hash or Array
  35 + meth = node['php-fpm']['pools'].method( is_hash ? :each : :each_with_index )
  36 + meth.call do |el1, el2|
  37 + key = is_hash ? el1 : el2
  38 + pool = is_hash ? el2 : el1
  39 + pool2 = mash_to_hash(pool)
  40 +
  41 + pool2['user'] = node['nginx']['user'] unless pool['user']
  42 + pool2['group'] = node['nginx']['user'] unless pool['group']
  43 + pool2['listen'] =
  44 + node['cfe-nginx-php-fpm']['php_fastcgi_socket'] unless pool['listen']
  45 +
  46 + node.default['php-fpm']['pools'][key] = pool2
  47 + end
  48 +end
  49 +
  50 +# Begin server configuration
  51 +
21 package 'openssl' 52 package 'openssl'
22 include_recipe 'php-fpm' 53 include_recipe 'php-fpm'
23 54
@@ -18,6 +18,13 @@ @@ -18,6 +18,13 @@
18 # limitations under the License. 18 # limitations under the License.
19 # 19 #
20 20
  21 +# Set derived attribute defaults inside recipe
  22 +
  23 +node.default['postfix']['main']['myhostname'] =
  24 + node['cfe-nginx-php-fpm']['postfix']['email_domain']
  25 +node.default['postfix']['main']['mydomain'] =
  26 + node['cfe-nginx-php-fpm']['postfix']['email_domain']
  27 +
21 include_recipe 'postfix' 28 include_recipe 'postfix'
22 29
23 remote_file node['postfix']['cafile'] do 30 remote_file node['postfix']['cafile'] do