cookbook-php-fpm icon indicating copy to clipboard operation
cookbook-php-fpm copied to clipboard

Recipe compile error

Open ameir opened this issue 10 years ago • 16 comments

When I simply do include_recipe "php-fpm", I get a recipe compile error. If I use the definition directly and install PHP-FPM from another recipe, it works fine. I think the solution would be to remove:

default['php-fpm']['pools'] = [ { :name => "www" } ] from the attributes.

Stack trace:

================================================================================
Recipe Compile Error in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/my_site/recipes/default.rb
================================================================================


TypeError
---------
can't convert Symbol into Integer

Cookbook Trace:
---------------
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/php-fpm/recipes/default.rb:123:in `[]'
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/php-fpm/recipes/default.rb:123:in `block in from_file'
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/php-fpm/recipes/default.rb:122:in `each'
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/php-fpm/recipes/default.rb:122:in `from_file'
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/apfaph/recipes/default.rb:1:in `from_file'
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/my_site/recipes/frontend.rb:8:in `from_file'
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/my_site/recipes/default.rb:38:in `from_file'


Relevant File Content:
----------------------
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/php-fpm/recipes/default.rb:

116:    service_name php_fpm_service_name
117:    supports :start => true, :stop => true, :restart => true, :reload => true
118:    action [ :enable, :start ]
119:  end
120:
121:  if node['php-fpm']['pools']
122:    node['php-fpm']['pools'].each do |pool|
123>>     php_fpm_pool pool[:name] do
124:        pool.each do |k, v|
125:          self.params[k.to_sym] = v
126:        end
127:      end
128:    end
129:  end130:```

ameir avatar Feb 28 '14 01:02 ameir

I'm having the same issue.

peteraba avatar Mar 28 '14 15:03 peteraba

guys, do you've an example of chef repo with that problem or some additional tips to help me reproduce the problem? I created my_site cookbook with include_recipe "php-fpm" and boostrapped with precise64.box - it worked...

yevgenko avatar Apr 05 '14 05:04 yevgenko

Could you try it with a CentOS 6.4 box? If it still works, I can try to get you more info when I'm back in the office.

ameir avatar Apr 06 '14 23:04 ameir

Ok, trying with the following box now https://github.com/2creatives/vagrant-centos/releases/tag/v0.1.0

yevgenko avatar Apr 12 '14 00:04 yevgenko

Ok, same issue here, used the following box because previous was too minimal (without chef): http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130731.box

yevgenko avatar Apr 12 '14 13:04 yevgenko

Actually in my case it failed earlier

NoMethodError
-------------
undefined method `[]' for nil:NilClass


Cookbook Trace:
---------------
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/php-fpm/recipes/default.rb:110:in `from_file'
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/my_site/recipes/default.rb:19:in `from_file'


Relevant File Content:
----------------------
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/php-fpm/recipes/default.rb:

103:    action :upgrade
104:  end
105:
106:  ruby_block "inspect node" do
107:    Chef::Log.info node.inspect
108:  end
109:
110>> template node['php-fpm']['conf_file'] do
111:    source "php-fpm.conf.erb"
112:    mode 00644
113:    owner "root"
114:    group "root"
115:    notifies :restart, "service[php-fpm]"
116:  end
117:
118:  service "php-fpm" do
119:    provider service_provider if service_provider

yevgenko avatar Apr 12 '14 17:04 yevgenko

Above issue gone after I added php-fpm as dependency into metadata.rb of my_site coobook Chef 11.12.2 CentOS 6.4

yevgenko avatar Apr 13 '14 19:04 yevgenko

Also tried with Chef 11.6.0, with in the following build: http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130731.box

Works fine as far as dependency is specified, otherwise I'm getting error, but it looks a bit different versus what you have @ameir

Could you please verify and possible provide more info for me? :)

Thanks.

yevgenko avatar Apr 13 '14 19:04 yevgenko

For what it's worth, I caused this error by mistakenly ignoring the directions and assuming that the pool name would be its key. I did

{
  "php-fpm": {
    "pools": {
      "www": {
        "listen": "127.0.0.1:9000"
      }
    }
  }
}

I needed:

{
  "php-fpm": {
    "pools": [ 
      {
        "name": "www",
        "listen": "127.0.0.1:9000"
      }
    ]
  }
}

winmillwill avatar May 02 '14 23:05 winmillwill

@ameir what do you think about it?

yevgenko avatar May 02 '14 23:05 yevgenko

Sorry for the delayed reply, @yevgenko. I ended up making some local tweaks to the cookbook to work around this a while back, and haven't had a chance to revert back to the original version due to time constraints. Feel free to close, unless @peteraba or others are still running into problems. Thanks!

ameir avatar May 10 '14 02:05 ameir

I am running into this issue as well.

nilesh in ~/github/knife-solo-secret on cloudgenius !
± knife solo bootstrap [email protected]                                                                      11:07
Bootstrapping Chef...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 15934  100 15934    0     0  34033      0 --:--:-- --:--:-- --:--:-- 63991
Downloading Chef 11.6.2 for ubuntu...
downloading https://www.opscode.com/chef/metadata?v=11.6.2&prerelease=false&nightlies=false&p=ubuntu&pv=12.04&m=x86_64
  to file /tmp/install.sh.1284/metadata.txt
trying wget...
url https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/12.04/x86_64/chef_11.6.2-1.ubuntu.12.04_amd64.deb
md5 a809b8cfeaea71c20c0de0e492c7f86f
sha256  74d5283b597299efbff3c66897c79876cc11aade6dc8810ddf38101526203651
downloaded metadata file looks valid...
downloading https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/12.04/x86_64/chef_11.6.2-1.ubuntu.12.04_amd64.deb
  to file /tmp/install.sh.1284/chef_11.6.2-1.ubuntu.12.04_amd64.deb
trying wget...
Comparing checksum with sha256sum...
Installing Chef 11.6.2
installing with dpkg...
Selecting previously unselected package chef.
(Reading database ... 51550 files and directories currently installed.)
Unpacking chef (from .../chef_11.6.2-1.ubuntu.12.04_amd64.deb) ...
Setting up chef (11.6.2-1.ubuntu.12.04) ...
Thank you for installing Chef!
Running Chef on 107.170.218.203...
Installing Librarian cookbooks...
Uploading the kitchen...
Generating solo config...
Running Chef...
Starting Chef Client, version 11.6.2
Compiling Cookbooks...
Recipe: ohai::default
  * remote_directory[/etc/chef/ohai_plugins] action create
    - create new directory /etc/chef/ohai_plugins
    - change mode from '' to '0755'Recipe: <Dynamically Defined Resource>
  * cookbook_file[/etc/chef/ohai_plugins/README] action create
    - create new file /etc/chef/ohai_plugins/README
    - update content in file /etc/chef/ohai_plugins/README from none to 775fa7
        --- /etc/chef/ohai_plugins/README   2014-05-10 14:12:06.112924000 -0400
        +++ /tmp/.README20140510-2895-grshfz    2014-05-10 14:12:06.116924000 -0400
        @@ -0,0 +1 @@
        +This directory contains custom plugins for Ohai.
    - change mode from '' to '0644'



Recipe: ohai::default
  * ohai[custom_plugins] action reload
    - re-run ohai and merge results into node attributes

[2014-05-10T14:12:06-04:00] WARN: Cloning resource attributes for service[nginx] from prior resource (CHEF-3694)
[2014-05-10T14:12:06-04:00] WARN: Previous service[nginx]: /root/chef-solo/cookbooks-2/nginx/recipes/default.rb:42:in `from_file'
[2014-05-10T14:12:06-04:00] WARN: Current  service[nginx]: /root/chef-solo/cookbooks-2/nginx/recipes/default.rb:49:in `from_file'

================================================================================
Recipe Compile Error in /root/chef-solo/cookbooks-2/php-fpm/recipes/default.rb
================================================================================


TypeError
---------
can't convert Symbol into Integer


Cookbook Trace:
---------------
  /root/chef-solo/cookbooks-2/php-fpm/recipes/default.rb:133:in `[]'
  /root/chef-solo/cookbooks-2/php-fpm/recipes/default.rb:133:in `block in from_file'
  /root/chef-solo/cookbooks-2/php-fpm/recipes/default.rb:132:in `each'
  /root/chef-solo/cookbooks-2/php-fpm/recipes/default.rb:132:in `from_file'


Relevant File Content:
----------------------
/root/chef-solo/cookbooks-2/php-fpm/recipes/default.rb:

126:    service_name php_fpm_service_name
127:    supports :start => true, :stop => true, :restart => true, :reload => true
128:    action [ :enable, :start ]
129:  end
130:  
131:  if node['php-fpm']['pools']
132:    node['php-fpm']['pools'].each do |pool|
133>>     php_fpm_pool pool[:name] do
134:        pool.each do |k, v|
135:          self.params[k.to_sym] = v
136:        end
137:      end
138:    end
139:  end
140:  


[2014-05-10T14:12:06-04:00] ERROR: Running exception handlers
[2014-05-10T14:12:06-04:00] ERROR: Exception handlers complete
[2014-05-10T14:12:06-04:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 3 resources updated
[2014-05-10T14:12:06-04:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
ERROR: RuntimeError: chef-solo failed. See output above.


lvnilesh avatar May 10 '14 18:05 lvnilesh

I am using version 0.6.8 of cookbook for php-fpm now. It is caused by wrong expression of array in "attributes/default.rb". That variable should be as follow.

default['php-fpm']['pools'] = {'name' => ['www'], 'listen' => ['127.0.0.1:9000']}

Also the 'each' statement in "recipes/default.rb" should be as follow.

if node['php-fpm']['pools']
  node['php-fpm']['pools'].each do |k,v|
         self.params[k.to_sym] = v
  end
end

I could make a progress tentatively.

raskolnikoff avatar May 31 '14 00:05 raskolnikoff

Any update on this issue? I'm running in the same issue on CentOS

htulipe avatar Sep 18 '14 08:09 htulipe

I had an issue in my own recipe that caused this error. Everything is working good now.

htulipe avatar Sep 18 '14 10:09 htulipe

We had a related issue that was also resolved by using the attributes syntax specified by @raskolnikoff. This issue can probably be marked as resolved, I think.

lukeasrodgers avatar Dec 23 '14 21:12 lukeasrodgers