On Tue, Aug 18, 2015 at 08:16:30AM -0700, Lunixer wrote:
> I was going through the Puppet Learning doc.
> Got to the template section and the ERB file, which is using the 'each'
> method to print the $real_servers.
> The puppet run fails with pointing to the 'each' method.
> Is this a bug? does anyone have any pointers?
>
> Using:
> centos 6.6
> puppet 3.8.1
> ruby 1.8.7
>
> Thanks.
>
> # cat /etc/puppet/modules/ntp/manifests/init.p
> class ntp {
>
> # Choose platform, package name, and config file name
> case $operatingsystem {
> centos, redhat: {
> $service_name = 'ntpd'
> $conf_file = 'ntp.conf'
> $default_servers = [ "0.centos.pool.ntp.org",
> "1.centos.pool.ntp.org",
> "2.centos.pool.ntp.org", ]
> }
> debian, ubuntu: {
> $service_name = 'ntp'
> $conf_file = 'ntp.conf.debian'
> $default_servers = [ "0.debian.pool.ntp.org iburst",
> "1.debian.pool.ntp.org iburst",
> "2.debian.pool.ntp.org iburst",
> "3.debian.pool.ntp.org iburst", ]
> }
> default: { fail("Unrecognized operating system for webserver") }
> }
>
> $servers_real = $default_servers
>
> # Install the package
> package { 'ntp':
> ensure => installed,
> }
>
> # Get the config file
> file { 'ntp.conf':
> path => '/etc/ntp.conf',
> ensure => file,
> require => Package['ntp'],
> content => template("ntp/${conf_file}.erb"),
> }
>
> # Manage the service
> service { 'ntp':
> name => $service_name,
> ensure => running,
> enable => true,
> subscribe => File['ntp.conf'],
> }
>
> } #class
>
>
>
> # cat /etc/puppet/modules/ntp/templates/ntp.conf.erb
> <% @servers_real.each do |this_server| -%>
> server <%= this_server %>
> <% end -%>
>
>
> # puppet agent --test
> Info: Retrieving pluginfacts
> Info: Retrieving plugin
> Info: Loading facts
> Error: Could not retrieve catalog from remote server: Error 400 on SERVER:
> Failed to parse template ntp/ntp.conf.erb:
> Filepath: /etc/puppet/modules/ntp/templates/ntp.conf.erb
> Line: 2
> Detail: undefined method `each' for nil:NilClass
> at /etc/puppet/modules/ntp/manifests/init.pp:26 on node
The error is not from the ruby version.
The template does not find @servers_real ( undefined method `each' for
nil:NilClass).
You could try to remove the file { 'ntp.conf': resource
and add a notify { $servers_real: } to check ifit is defined.
--
(o- Julien Pivotto
//\ Open-Source Consultant
V_/_ Inuits - https://www.inuits.eu
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/20150820070609.GA14557%40nitrogen.
For more options, visit https://groups.google.com/d/optout.
signature.asc
Description: PGP signature
