Never used that, but it sounds like your instructions are using the Puppet 4 
("future") parser but your Learning VM or locally installed puppet is using the 
version 3 parser.

https://docs.puppetlabs.com/puppet/latest/reference/experiments_future.html

As to how to fix this, you might set your parser to "future", or you might 
update from yum.puppetlabs.com, or something similar.

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
>    puppetmaster.example.com
>    Warning: Not using cache on failed catalog
>    Error: Could not retrieve catalog; skipping run
> 
>    --
>    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 [1]puppet-users+unsubscr...@googlegroups.com.
>    To view this discussion on the web visit
>    
> [2]https://groups.google.com/d/msgid/puppet-users/5d089681-9deb-4806-a3b1-4dbaa5bbe1d6%40googlegroups.com.
>    For more options, visit [3]https://groups.google.com/d/optout.
> 
> References
> 
>    Visible links
>    1. mailto:puppet-users+unsubscr...@googlegroups.com
>    2. 
> https://groups.google.com/d/msgid/puppet-users/5d089681-9deb-4806-a3b1-4dbaa5bbe1d6%40googlegroups.com?utm_medium=email&utm_source=footer
>    3. https://groups.google.com/d/optout

-- 
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 puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/20150818160122.GA9555%40iniquitous.heresiarch.ca.
For more options, visit https://groups.google.com/d/optout.

Reply via email to