Ask Your Question

probelm getting "each" function to work

asked 2016-03-01 18:47:56 -0600

ancymathews gravatar image

updated 2016-03-02 09:40:49 -0600

new to puppet.

I am having issue with "each" function to work on my array. code is:

include stdlib
$data = ["one","two","three"]
$data.each |String $val| { notify {"$val":} }

Error: Enterprise 3.7.2)

Error: Could not parse for environment production: Syntax error at '.' at /etc/puppetlabs/puppet/modules/ora_patch/tests/test.pp:4 on node

What am I doing wrong?

Thanks, Ancy

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2016-03-02 09:48:34 -0600

The confusion appears to be that "each" is not a function in stdlib; it's grammar in the DSL in Puppet 4. You, however, are using Puppet 3, and I assume you don't have the Future Parser enabled. You could upgrade to a later version of Puppet Enterprise, or enable the Future Parser according to instructions here.

edit flag offensive delete link more


That was it! I was running version 3.7 . I enabled the future parser like you suggested and the code worked just fine. Thanks for your quick response.

ancymathews gravatar imageancymathews ( 2016-03-02 11:32:35 -0600 )edit

answered 2016-03-02 09:07:05 -0600

Mr_Sharma gravatar image

Hi Ancy, well there's nothing wrong with your each statement. It's should work fine. For quick testing, you can put the following code snippet in site.pp of your production environment(Please check if production environment is referring to the correct module path).

class dummy {
$data = ["one","two","three"]
$data.each |String $val|
{ notify {"$val":} }

# Agent node
node "" {
 include dummy

Run puppet agent -t on your agent node to test above. It's working fine for me as follows:

[root@node1 ~]# puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for node1
Info: Applying configuration version '1456930709'
Notice: one
Notice: /Stage[main]/Dummy/Notify[one]/message: defined 'message' as 'one'
Notice: two
Notice: /Stage[main]/Dummy/Notify[two]/message: defined 'message' as 'two'
Notice: three
Notice: /Stage[main]/Dummy/Notify[three]/message: defined 'message' as 'three'
Notice: Applied catalog in 0.42 seconds
[root@node1 ~]#

It seems, your agent is reporting to some other environment than production. Please check.

edit flag offensive delete link more


I was problem with the version I was running. "each" is supported on version 4 and above. I had 3.7. However, it worked when future parser was enabled.

ancymathews gravatar imageancymathews ( 2016-03-02 11:33:58 -0600 )edit

Great. It worked well at my side because I am running on PE 2015.2.

Mr_Sharma gravatar imageMr_Sharma ( 2016-03-02 12:17:16 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-03-01 18:47:56 -0600

Seen: 111 times

Last updated: Mar 02 '16