0.7.14 -> 0.7.16... issues

My client Machines that have been updated to:

0.7.16

are displaying:

/usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/resource.rb:72:in
method_missing': undefined methodmaster’ for
Chef::Resource::Template (NoMethodError)
from /usr/local/chef/cache/cookbooks/snmp/recipes/default.rb:
47:in from_file' from /usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/mixin/ recipe_definition_dsl_core.rb:68:ininstance_eval’
from /usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/mixin/
recipe_definition_dsl_core.rb:68:in method_missing' from /usr/local/chef/cache/cookbooks/snmp/recipes/default.rb: 37:infrom_file’
from /usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/
cookbook.rb:166:in load_recipe' from /usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/ compile.rb:156:inload_recipes’
from /usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/
compile.rb:142:in each' from /usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/ compile.rb:142:inload_recipes’
… 7 levels…
from /usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/
application.rb:57:in run' from /usr/lib/ruby/gems/1.8/gems/chef-0.7.16/bin/chef-client:26 from /usr/bin/chef-client:19:inload’
from /usr/bin/chef-client:19

What needs to be fixed?

Bill Levering
idbill@planx.com
KFP: 0C38 4D7E 5B50 94FE 992D 406D 6C81 DE33 5459 A1AC

Hi Bill,
seems like it's a problem in that snmp cookbook. Can you show us the
default.rb recipe?

Thanks,
Dan DeLeo

On Mon, Feb 8, 2010 at 6:32 PM, Bill Levering idbill@planx.com wrote:

My client Machines that have been updated to:

0.7.16

are displaying:

/usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/resource.rb:72:in
method_missing': undefined method master' for Chef::Resource::Template
(NoMethodError)
from /usr/local/chef/cache/cookbooks/snmp/recipes/default.rb:47:in
from_file' from /usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/mixin/recipe_definition_dsl_core.rb:68:in instance_eval'
from
/usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/mixin/recipe_definition_dsl_core.rb:68:in
method_missing' from /usr/local/chef/cache/cookbooks/snmp/recipes/default.rb:37:in from_file'
from
/usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/cookbook.rb:166:in
load_recipe' from /usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/compile.rb:156:in load_recipes'
from
/usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/compile.rb:142:in each' from /usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/compile.rb:142:in load_recipes'
... 7 levels...
from
/usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/application.rb:57:in run' from /usr/lib/ruby/gems/1.8/gems/chef-0.7.16/bin/chef-client:26 from /usr/bin/chef-client:19:in load'
from /usr/bin/chef-client:19

What needs to be fixed?

Bill Levering
idbill@planx.com
KFP: 0C38 4D7E 5B50 94FE 992D 406D 6C81 DE33 5459 A1AC

Interesting...

in recipe.rb I had:
template "/etc/snmp/snmpd.conf" do
backup 0
mode 0444
owner "root"
group "root"
path "/etc/snmp/snmpd.conf"
variables(
:community => node[:community][:string],
:mrtgserver => "172.16.11.201/32",
:opennmsserver => "172.16.11.235/32",
:extradisk => node[:community][:disk],
:snmp-master => node[:community][:master],
:hostname => node[:hostname]
)
source "snmp.conf.erb"
action :create
end

template snmp.conf.erb had:
<%= @snmp-master %>

and attributes/community_strings.rb had:
community Mash.new unless attribute?("community")

case hostname

when "watchmen"
community[:string] = "*******"
community[:disk] = ""
community[:master] = ""

I changed all instances of master to snmpmaster
and snmp-master to snmpmaster

at it works in 0.7.16

Would this be a reserved variable?

Bill

Bill Levering
idbill@planx.com
KFP: 0C38 4D7E 5B50 94FE 992D 406D 6C81 DE33 5459 A1AC

On Feb 8, 2010, at 11:21 PM, Daniel DeLeo wrote:

Hi Bill,
seems like it's a problem in that snmp cookbook. Can you show us the
default.rb recipe?

Thanks,
Dan DeLeo

On Mon, Feb 8, 2010 at 6:32 PM, Bill Levering idbill@planx.com
wrote:

My client Machines that have been updated to:

0.7.16

are displaying:

/usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/resource.rb:72:in
method_missing': undefined method master' for
Chef::Resource::Template
(NoMethodError)
from /usr/local/chef/cache/cookbooks/snmp/recipes/default.rb:
47:in
from_file' from /usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/mixin/ recipe_definition_dsl_core.rb:68:in instance_eval'
from
/usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/mixin/
recipe_definition_dsl_core.rb:68:in
method_missing' from /usr/local/chef/cache/cookbooks/snmp/recipes/default.rb: 37:in from_file'
from
/usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/cookbook.rb:166:in
load_recipe' from /usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/compile.rb:156:in load_recipes'
from
/usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/compile.rb:142:in
each' from /usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/compile.rb:142:in load_recipes'
... 7 levels...
from
/usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/application.rb:
57:in run' from /usr/lib/ruby/gems/1.8/gems/chef-0.7.16/bin/chef-client: 26 from /usr/bin/chef-client:19:in load'
from /usr/bin/chef-client:19

What needs to be fixed?

Bill Levering
idbill@planx.com
KFP: 0C38 4D7E 5B50 94FE 992D 406D 6C81 DE33 5459 A1AC

This is perplexing: I can't find anywhere that variable or method
"master" is used in Chef. From your stack trace it looks like you were
calling the method "master" on the template resource somehow (as an
aside, resources now implement the recipe DSL to support LWRP and the
deploy resource's embedded recipe callbacks, but this first appeared
in 0.7.12, nothing new in 0.7.16). Is it possible that you changed
something else at the same time you upgraded?

Dan DeLeo

On Tue, Feb 9, 2010 at 9:09 AM, Bill Levering idbill@planx.com wrote:

Interesting...

in recipe.rb I had:
template "/etc/snmp/snmpd.conf" do
backup 0
mode 0444
owner "root"
group "root"
path "/etc/snmp/snmpd.conf"
variables(
:community => node[:community][:string],
:mrtgserver => "172.16.11.201/32",
:opennmsserver => "172.16.11.235/32",
:extradisk => node[:community][:disk],
:snmp-master => node[:community][:master],
:hostname => node[:hostname]
)
source "snmp.conf.erb"
action :create
end

template snmp.conf.erb had:
<%= @snmp-master %>

and attributes/community_strings.rb had:
community Mash.new unless attribute?("community")

case hostname

when "watchmen"
community[:string] = "*******"
community[:disk] = ""
community[:master] = ""

I changed all instances of master to snmpmaster
and snmp-master to snmpmaster

at it works in 0.7.16

Would this be a reserved variable?

Bill

Bill Levering
idbill@planx.com
KFP: 0C38 4D7E 5B50 94FE 992D 406D 6C81 DE33 5459 A1AC

On Feb 8, 2010, at 11:21 PM, Daniel DeLeo wrote:

Hi Bill,
seems like it's a problem in that snmp cookbook. Can you show us the
default.rb recipe?

Thanks,
Dan DeLeo

On Mon, Feb 8, 2010 at 6:32 PM, Bill Levering idbill@planx.com wrote:

My client Machines that have been updated to:

0.7.16

are displaying:

/usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/resource.rb:72:in
method_missing': undefined method master' for Chef::Resource::Template
(NoMethodError)
from /usr/local/chef/cache/cookbooks/snmp/recipes/default.rb:47:in
`from_file'
from

/usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/mixin/recipe_definition_dsl_core.rb:68:in
`instance_eval'
from

/usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/mixin/recipe_definition_dsl_core.rb:68:in
method_missing' from /usr/local/chef/cache/cookbooks/snmp/recipes/default.rb:37:in from_file'
from
/usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/cookbook.rb:166:in
load_recipe' from /usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/compile.rb:156:in load_recipes'
from
/usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/compile.rb:142:in each' from /usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/compile.rb:142:in load_recipes'
... 7 levels...
from
/usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/application.rb:57:in
run' from /usr/lib/ruby/gems/1.8/gems/chef-0.7.16/bin/chef-client:26 from /usr/bin/chef-client:19:in load'
from /usr/bin/chef-client:19

What needs to be fixed?

Bill Levering
idbill@planx.com
KFP: 0C38 4D7E 5B50 94FE 992D 406D 6C81 DE33 5459 A1AC

Could it be bad interpretation of snmp-master (the dash causing the
problem)?

Many things were updated....
Jan 28 10:42:00 Updated: libgcc-4.1.2-46.el5_4.2.x86_64
Jan 28 10:42:03 Updated: rubygem-chef-server-slice-0.7.16-1.el5.noarch
Jan 28 10:42:10 Updated: tzdata-2009u-1.el5.noarch
Jan 28 10:43:01 Updated: glibc-common-2.5-42.el5_4.3.x86_64
Jan 28 10:43:14 Updated: glibc-2.5-42.el5_4.3.x86_64
Jan 28 10:43:20 Updated: util-linux-2.13-0.52.el5_4.1.x86_64
Jan 28 10:43:21 Updated: kpartx-0.4.7-30.el5_4.4.x86_64
Jan 28 10:43:24 Updated: selinux-policy-2.4.6-255.el5_4.4.noarch
Jan 28 10:43:26 Updated: device-mapper-multipath-0.4.7-30.el5_4.4.x86_64
Jan 28 10:43:27 Updated: gzip-1.3.5-11.el5.centos.1.x86_64
Jan 28 10:43:30 Updated: ksh-20080202-14.el5_4.2.x86_64
Jan 28 10:43:31 Updated: 4:vixie-cron-4.1-77.el5_4.1.x86_64
Jan 28 10:43:32 Updated: tcsh-6.14-14.el5_4.3.x86_64
Jan 28 10:43:32 Updated: acpid-1.0.4-9.el5_4.2.x86_64
Jan 28 10:44:00 Updated: selinux-policy-
targeted-2.4.6-255.el5_4.4.noarch
Jan 28 10:44:02 Updated: yum-utils-1.1.16-14.el5.centos.1.noarch
Jan 28 10:44:05 Updated: rpmforge-release-0.5.1-1.el5.rf.x86_64
Jan 28 10:44:06 Updated: yum-fastestmirror-1.1.16-14.el5.centos.1.noarch
Jan 28 10:44:07 Updated: ruby-mode-1.8.5-5.el5_4.8.x86_64
Jan 28 10:44:10 Updated: rubygem-daemons-1.0.10-1.el5.noarch
Jan 28 10:44:14 Updated: ruby-docs-1.8.5-5.el5_4.8.x86_64
Jan 28 10:44:14 Updated: yum-priorities-1.1.16-14.el5.centos.1.noarch
Jan 28 10:45:12 Installed: kernel-xen-2.6.18-164.11.1.el5.x86_64
Jan 28 10:45:17 Updated: glibc-2.5-42.el5_4.3.i686
Jan 28 10:45:17 Updated: krb5-libs-1.6.1-36.el5_4.1.x86_64
Jan 28 10:45:18 Updated: krb5-libs-1.6.1-36.el5_4.1.i386
Jan 28 10:45:21 Updated: openssl-0.9.8e-12.el5_4.1.x86_64
Jan 28 10:45:27 Updated: ruby-libs-1.8.5-5.el5_4.8.x86_64
Jan 28 10:45:28 Updated: openssl-0.9.8e-12.el5_4.1.i686
Jan 28 10:45:29 Updated: ruby-libs-1.8.5-5.el5_4.8.i386
Jan 28 10:45:31 Updated: ruby-1.8.5-5.el5_4.8.x86_64
Jan 28 10:45:32 Updated: libgcc-4.1.2-46.el5_4.2.i386
Jan 28 10:45:33 Updated: libstdc++-4.1.2-46.el5_4.2.x86_64
Jan 28 10:45:33 Updated: expat-1.95.8-8.3.el5_4.2.x86_64
Jan 28 10:45:35 Updated: rubygem-fastthread-1.0.7-1.el5.x86_64
Jan 28 10:45:38 Updated: krb5-workstation-1.6.1-36.el5_4.1.x86_64
Jan 28 10:45:38 Updated: libstdc++-4.1.2-46.el5_4.2.i386
Jan 28 10:45:39 Updated: expat-1.95.8-8.3.el5_4.2.i386
Jan 28 10:45:52 Updated: rubygem-chef-0.7.16-1.el5.noarch
Jan 28 10:45:53 Updated: ruby-irb-1.8.5-5.el5_4.8.x86_64
Jan 28 10:45:54 Updated: ruby-rdoc-1.8.5-5.el5_4.8.x86_64
Jan 28 10:46:09 Updated: ruby-ri-1.8.5-5.el5_4.8.x86_64
Jan 28 10:46:12 Updated: ruby-devel-1.8.5-5.el5_4.8.x86_64
Jan 28 10:46:39 Updated: rubygem-rspec-1.2.9-1.el5.noarch
Jan 28 10:46:49 Updated: rubygem-chef-server-0.7.16-1.el5.noarch
Jan 28 10:46:50 Updated: ruby-devel-1.8.5-5.el5_4.8.i386
Jan 28 10:46:39 Updated: rubygem-rspec-1.2.9-1.el5.noarch
Jan 28 10:46:49 Updated: rubygem-chef-server-0.7.16-1.el5.noarch
Jan 28 10:46:50 Updated: ruby-devel-1.8.5-5.el5_4.8.i386

Bill Levering
idbill@planx.com
KFP: 0C38 4D7E 5B50 94FE 992D 406D 6C81 DE33 5459 A1AC

On Feb 9, 2010, at 10:09 AM, Daniel DeLeo wrote:

This is perplexing: I can't find anywhere that variable or method
"master" is used in Chef. From your stack trace it looks like you were
calling the method "master" on the template resource somehow (as an
aside, resources now implement the recipe DSL to support LWRP and the
deploy resource's embedded recipe callbacks, but this first appeared
in 0.7.12, nothing new in 0.7.16). Is it possible that you changed
something else at the same time you upgraded?

Dan DeLeo

On Tue, Feb 9, 2010 at 9:09 AM, Bill Levering idbill@planx.com
wrote:

Interesting...

in recipe.rb I had:
template "/etc/snmp/snmpd.conf" do
backup 0
mode 0444
owner "root"
group "root"
path "/etc/snmp/snmpd.conf"
variables(
:community => node[:community][:string],
:mrtgserver => "172.16.11.201/32",
:opennmsserver => "172.16.11.235/32",
:extradisk => node[:community][:disk],
:snmp-master => node[:community][:master],
:hostname => node[:hostname]
)
source "snmp.conf.erb"
action :create
end

template snmp.conf.erb had:
<%= @snmp-master %>

and attributes/community_strings.rb had:
community Mash.new unless attribute?("community")

case hostname

when "watchmen"
community[:string] = "*******"
community[:disk] = ""
community[:master] = ""

I changed all instances of master to snmpmaster
and snmp-master to snmpmaster

at it works in 0.7.16

Would this be a reserved variable?

Bill

Bill Levering
idbill@planx.com
KFP: 0C38 4D7E 5B50 94FE 992D 406D 6C81 DE33 5459 A1AC

On Feb 8, 2010, at 11:21 PM, Daniel DeLeo wrote:

Hi Bill,
seems like it's a problem in that snmp cookbook. Can you show us the
default.rb recipe?

Thanks,
Dan DeLeo

On Mon, Feb 8, 2010 at 6:32 PM, Bill Levering idbill@planx.com
wrote:

My client Machines that have been updated to:

0.7.16

are displaying:

/usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/resource.rb:72:in
method_missing': undefined method master' for
Chef::Resource::Template
(NoMethodError)
from /usr/local/chef/cache/cookbooks/snmp/recipes/
default.rb:47:in
`from_file'
from

/usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/mixin/
recipe_definition_dsl_core.rb:68:in
`instance_eval'
from

/usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/mixin/
recipe_definition_dsl_core.rb:68:in
method_missing' from /usr/local/chef/cache/cookbooks/snmp/recipes/ default.rb:37:in from_file'
from
/usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/cookbook.rb:166:in
load_recipe' from /usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/compile.rb:156:in load_recipes'
from
/usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/compile.rb:
142:in each' from /usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/compile.rb:142:in load_recipes'
... 7 levels...
from
/usr/lib/ruby/gems/1.8/gems/chef-0.7.16/lib/chef/application.rb:
57:in
run' from /usr/lib/ruby/gems/1.8/gems/chef-0.7.16/bin/chef- client:26 from /usr/bin/chef-client:19:in load'
from /usr/bin/chef-client:19

What needs to be fixed?

Bill Levering
idbill@planx.com
KFP: 0C38 4D7E 5B50 94FE 992D 406D 6C81 DE33 5459 A1AC

$ ruby -e "puts :snmp-master"
-e:1: undefined local variable or method `master' for main:Object (NameError)

Dont use hyphen (dash) as part of symbol identifiers.
it should be safe underscore

template "/etc/snmp/snmpd.conf" do
backup 0
mode 0444
owner "root"
group "root"
path "/etc/snmp/snmpd.conf"
variables(
:community => node[:community][:string],
:mrtgserver => "172.16.11.201/32",
:opennmsserver => "172.16.11.235/32",
:extradisk => node[:community][:disk],

  •  :snmp-master => node[:community][:master],
    
  •  :snmp_master => node[:community][:master],
    

I believe a dash is a valid character for an identifier/symbol in ruby

On Feb 9, 2010, at 1:08 PM, dreamcat four wrote:

$ ruby -e "puts :snmp-master"
-e:1: undefined local variable or method `master' for main:Object (NameError)

Dont use hyphen (dash) as part of symbol identifiers.
it should be safe underscore

template "/etc/snmp/snmpd.conf" do
backup 0
mode 0444
owner "root"
group "root"
path "/etc/snmp/snmpd.conf"
variables(
:community => node[:community][:string],
:mrtgserver => "172.16.11.201/32",
:opennmsserver => "172.16.11.235/32",
:extradisk => node[:community][:disk],

  •  :snmp-master => node[:community][:master],
    
  •  :snmp_master => node[:community][:master],
    

On Tue, Feb 09, 2010 at 01:32:05PM -0800, Alex Soto wrote:

I believe a dash is a valid character for an identifier/symbol in ruby

it is but you need to wrap it in quotes.

h = {}
=> {}
h[:snmp-master] = "foo"
NoMethodError: undefined method `-' for :snmp:Symbol
from (irb):4
h[':snmp-master'] = "foo"
=> "foo"

--
Mathieu Sauve-Frankel

Hi,

I think what you have to appreciate is that its a good programming
practise to replace questionable characters with an underscore in
identifiers and variable names. Regardless whether its a macro, a
constant, a symbol or an instance variable. Not only is it a
convention in other programming languages, its heavily the convention
in ruby. To try to use a dash instead offers few benefit, is not
needed for the functional execution of code, and creates more barrier
for other programmers who might want to come along and improve the
code.

In Bill's case its necessary for him to use an underscore instead of a
dash ('-') for the identifier symbol :snmp_master. The symbol's string
is converted into an instance variable. It may fail when encountering
a dash during the conversion later on.

Imagine this situation:

$ @snmp-master = true
NoMethodError: undefined method `-' for nil:NilClass
from (irb):12
from :0

wheras an underscore can slip through un-noticed

$ @snmp_master = true
=> true

However, that said,

When you wrap something in quotes, then its a string.
So its not a symbol. We were discussing symbols, right?

$ ruby -e "puts ':snmp-master'.class"
String

So your example isn't right if you were hoping to agree with Alex.
Although yes it is possible to prefix any string with colon : char.

Then ruby will turn the enclosed string into a symbol.

$ 'snmp-master'.to_sym
=> :"snmp-master"

$ 'snmp-master'.to_sym.class
=> Symbol

$ 'snmp-master'.to_sym.to_s
=> "snmp-master"

$ :snmp_master.to_s
=> "snmp_master"

Its bad idea because it can lead to a weird bug in other places.

In Ruby we are often converting between symbols and variables.
The assumption is everywhere that only underscore is allowed.

So Mathieu and Alex,
Please follow this programming convention if you want fewer bugs

On Wed, Feb 10, 2010 at 2:50 AM, msf msf@kisoku.net wrote:

On Tue, Feb 09, 2010 at 01:32:05PM -0800, Alex Soto wrote:

I believe a dash is a valid character for an identifier/symbol in ruby

it is but you need to wrap it in quotes.

h = {}
=> {}
h[:snmp-master] = "foo"
NoMethodError: undefined method `-' for :snmp:Symbol
from (irb):4
h[':snmp-master'] = "foo"
=> "foo"

--
Mathieu Sauve-Frankel