Puppetlabs-dhcp - Failed to parse template dhcp/dhcp.pool.erb, undefined method each

674 views
Skip to first unread message

Peter

unread,
Jan 23, 2013, 5:55:57 PM1/23/13
to puppet...@googlegroups.com
Hi List,

After installing the puppetlabs-dhcp module and trying to run the tests/init.pp file I receive and error see below for sequence:


puppet module install zleslie/dhcp
Notice: Preparing to install into /etc/puppet/modules ...
Notice: Downloading from https://forge.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
/etc/puppet/modules
âââ zleslie-dhcp (v1.1.0)


(**Needed to install the concat dependacy for the Puppetlabs-dhcp module.  Raised a github issue (#17) to include the dependency in the module**)

puppet module install ripienaar/concat
Notice: Preparing to install into /etc/puppet/modules ...
Notice: Downloading from https://forge.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
/etc/puppet/modules
âââ ripienaar-concat (v0.2.0)



puppet apply /etc/puppet/modules/dhcp/tests/init.pp --verbose
Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/pe_version.rb
Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/root_home.rb
Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/puppet_vardir.rb
Info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/facter_dot_d.rb
Info: Loading facts in /etc/puppet/modules/concat/lib/facter/concat_basedir.rb
Warning: Config file /etc/puppet/hiera.yaml not found, using Hiera defaults
Error: Failed to parse template dhcp/dhcpd.pool.erb:
  Filepath: /etc/puppet/modules/dhcp/templates/dhcpd.pool.erb
  Line: 7
  Detail: undefined method `each' for "10.1.1.100 10.1.1.200":String
 at /etc/puppet/modules/dhcp/manifests/pool.pp:15 on node creator.mgnt.local
Error: Failed to parse template dhcp/dhcpd.pool.erb:
  Filepath: /etc/puppet/modules/dhcp/templates/dhcpd.pool.erb
  Line: 7
  Detail: undefined method `each' for "10.1.1.100 10.1.1.200":String
 at /etc/puppet/modules/dhcp/manifests/pool.pp:15 on node creator.mgnt.local





My question is what could be causing this?  I assume that this is something to do with Puppet's DSL?

Thanks,

Peter



Peter

unread,
Jan 24, 2013, 6:20:46 AM1/24/13
to puppet...@googlegroups.com
Not sure if it is the reason but making the change seems to fix it.  Just incase anyone else comes across this in the future.

The init.pp file calling the Pool's template (https://github.com/puppetlabs/puppetlabs-dhcp/blob/master/tests/init.pp) is passing a string not an array hence the variable not having an each method (see below for extract)

dhcp::pool{ 'example.com':
  network => '10.1.1.0',
  mask => '255.255.255.0',
  range => '10.1.1.100 10.1.1.200',
  gateway => '10.1.1.1',
}


By changing the underlined and bolded part to ['10.1.1.100', '10.1.1.200'] fixed the error ... go figure.  Not sure some ruby setting on my end is not tweaked right or these things get through the test harness?

Peter.

Alex Scoble

unread,
Nov 20, 2013, 3:24:03 PM11/20/13
to puppet...@googlegroups.com
When I change it to an array it injects a comma into the range and DHCP pukes.

Alex Scoble

unread,
Nov 20, 2013, 3:27:26 PM11/20/13
to puppet...@googlegroups.com
Nevermind. I think the problem was that I was splitting it up into two members of an array with a comma as opposed to just keeping it one long string. So yeah, this fix worked.

Thanks,

Alex
Reply all
Reply to author
Forward
0 new messages