Ask Your Question

error in iteration using .each [closed]

asked 2015-06-12 11:04:34 -0600

DX gravatar image

updated 2015-06-12 14:19:49 -0600

I am trying to create multiple directories, the parent directories exist. I am using a .each statement inside a case statement. Here's one case:

  'srvr4':    {
                  file { "/opt/kafka_2.10-" :
                      ensure  => file,
                      owner   => root,
                      mode    => '0644',
                      content => template ("/etc/puppet/modules/aspen/templates/"),
                      replace => 'yes',
                  $dnames = ['1', '2', '3', '4']
                  $dnames.each |$dname| {
                      file {"/mnt/hdfs/$dname/newdir":
                          ensure => directory,

I get the following error in the line $dnames.each |$dname| { :

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Syntax error at '.'; expected '}'

I am new working puppet.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by DX
close date 2015-06-15 10:17:11.414797

1 Answer

Sort by ยป oldest newest most voted

answered 2015-06-12 23:17:58 -0600

GregLarkin gravatar image

What version of Puppet are you using, and do you have the future parser enabled? The .each iterator (and other iterators) are only available when the future parser is enabled.


edit flag offensive delete link more


I am using 4.1, got the info about the .each statement from the same page you suggest, but didn't know about the parser.

DX gravatar imageDX ( 2015-06-14 00:57:39 -0600 )edit

4.1 has the future parser enabled, so there must be some other syntax error in the code. I suggest taking just the part using the iterator and putting it into a separate .pp file that you can test with puppet apply until you find the problem. It looks like it should work, though.

GregLarkin gravatar imageGregLarkin ( 2015-06-14 10:43:34 -0600 )edit

Got it, thank you!

DX gravatar imageDX ( 2015-06-15 10:16:33 -0600 )edit

Question Tools

1 follower


Asked: 2015-06-12 11:04:34 -0600

Seen: 525 times

Last updated: Jun 12 '15