Ask Your Question
0

Error: Could not parse for environment production: Syntax error at '.'

asked 2017-10-19 01:46:16 -0600

esxi1979 gravatar image

Hello All,

Here is the .pp file i am running

$nics = $facts['networking']['interfaces'] $nics.each | String $interface, Hash $attributes | { notice("Interface ${interface} has IP ${attributes['ip']}") }

Error: Could not parse for environment production: Syntax error at '.' at ..iterationhash.pp:2 on node xx Error: Could not parse for environment production: Syntax error at '.' at ..iterationhash.pp:2 on node xx

pls suggest what i am doing wrong.

thanks

edit retag flag offensive close merge delete

Comments

Strange. You do have PP ≥ 4.0, don't you? … Is this the whole content of your `*.pp` file? You usually put everything in a `class foo {}` body. What have you stripped from the error message?

Kai Burghardt gravatar imageKai Burghardt ( 2017-10-19 10:52:45 -0600 )edit

hello Kai, below is my puppet version. puppet --version 3.8.7 yes the full file is as below $nics = $facts['networking']['interfaces'] $nics.each | String $interface, Hash $attributes | { notice('Interface ${interface} has IP ${attributes['ip']}') }

esxi1979 gravatar imageesxi1979 ( 2017-10-19 16:19:39 -0600 )edit

in the err message i removed the server name Error: Could not parse for environment production: Syntax error at '.' at /root/puppet/puppet/manifests/iteration_hash-v1.pp:2 on node xx ..

esxi1979 gravatar imageesxi1979 ( 2017-10-19 16:23:04 -0600 )edit

You do have the the (then) “future” parser enabled, don't you? https://docs.puppet.com/puppet/3.8/configuration.html#parser Also, given PP version 3.8 your clients are probably paired with facter version 2.x. This facter version did not know the “modern” fact you're trying to access.

Kai Burghardt gravatar imageKai Burghardt ( 2017-10-19 18:05:14 -0600 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2017-10-19 10:53:04 -0600

cler gravatar image

I am away from computer so I cannot test but when performing iteration with the each function you do it over an array or a hash, in your case this would be $nics, Is $nics is an array or hash? If it is one of those then follow the use cases in here https://puppet.com/docs/puppet/5.3/fu... . It it isnt any of those data types, think of another way to achieve what you want to do. I dont think you are allowed to have a hash in here | String $interface, Hash $attributes | --> $attributes

edit flag offensive delete link more

Comments

$nics is defined in the line above and just accesses the fact `networking.interfaces`. esxi1979 _is_ attempting to use the `each()` function. He*she knows what they're doing.

Kai Burghardt gravatar imageKai Burghardt ( 2017-10-19 10:57:07 -0600 )edit

ok my bad then

cler gravatar imagecler ( 2017-10-19 11:33:36 -0600 )edit

`networking.interfaces` has a well defined structure https://puppet.com/docs/facter/latest/core_facts.html#networking There's no ambiguity, unless exsi1979 works in a heterogen environment with various (major) facter versions (“legacy” vs. “modern” facts), where she*he has to employ branches.

Kai Burghardt gravatar imageKai Burghardt ( 2017-10-19 12:13:01 -0600 )edit

here is expected output Notice: Scope(Class[main]): Interface enp0s3 has IP 10.0.2.15 Notice: Scope(Class[main]): Interface lo has IP 127.0.0.1

esxi1979 gravatar imageesxi1979 ( 2017-10-19 17:20:17 -0600 )edit

my point was that it would be nice to check the $nic data type. I am using old versions of puppet and facter and thought that might be the problem. that is all

cler gravatar imagecler ( 2017-10-20 00:20:38 -0600 )edit
-1

answered 2017-10-19 10:22:43 -0600

ramkrishnayadav gravatar image

Puppet does not like dot in the variable names. Replace the variable $nics.each to $nics_each and try

edit flag offensive delete link more

Comments

sorry that did not helped Error: Could not parse for environment production: Could not match | at iteration_hash-v1.pp:2 on node xx Error: Could not parse for environment production: Could not match | at iteration_hash-v1.pp:2 on node xx

esxi1979 gravatar imageesxi1979 ( 2017-10-19 16:18:05 -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

Stats

Asked: 2017-10-19 01:46:16 -0600

Seen: 51 times

Last updated: Oct 19