7

Here is my little puppet snippet: when i execute this snippet i got the following error:

err: Could not parse for environment production: Could not match   at /home/test.pp:8

$vendor = generate("/usr/bin/lsscsi")

if defined($vendor) {
    if $vendor =~ /LSI/{
        $d_multipath = [{
            vendor => 'LSI',
            product => 'INF-01-00',
            path_checker => 'rdac',
            path_selector => 'round-robin 0',
       }]
    }
}
else {
    notify {'faield-lsscsi':
        message  => "ERROR: failed to execute lsscsi to get the scsi vendor type",
        loglevel => critical,
    }
}

Could some one please help in pointing out?

kenorb
  • 155,785
  • 88
  • 678
  • 743
James Sapam
  • 16,036
  • 12
  • 50
  • 73
  • The error is not related the code you pasted, and maybe you can try to run `puppet apply --environment=production` – BMW Dec 12 '14 at 23:33
  • 2
    https://docs.puppetlabs.com/learning/manifests.html#syntax-hints – BMW Dec 12 '14 at 23:43
  • 1
    I check the code with `puppet parser validate test.pp`, no error is reported. Do you paste all codes here? – BMW Dec 12 '14 at 23:47
  • Ya i got that error while running validate. and i am not able to install puppet-lint. – James Sapam Dec 12 '14 at 23:52
  • 1
    I copy/paste the code on my environment and run with validate, didn't get any errors. Are there any hide characters in the pp file? – BMW Dec 12 '14 at 23:55
  • 1
    can you remove `[` and `]` on line 5 and 10, then try again? – BMW Dec 12 '14 at 23:56

4 Answers4

9

Regarding error Could not parse for environment production, you can check url https://docs.puppetlabs.com/learning/manifests.html#syntax-hints

Syntax Hints

Watch out for these common errors:

Don’t forget commas and colons! Forgetting them causes errors like Could not parse for environment production: Syntax error at 'mode'; expected '}' at /root/manifests/1.file.pp:6 on node learn.localdomain.

Capitalization matters! The resource type and the attribute names should always be lowercase.
The values used for titles and attribute values will usually be strings, which you should usually quote. Read more about Puppet’s data types here.

There are two kinds of quotes in Puppet: single (') and double ("). The main difference is that double quotes let you interpolate $variables, which we cover in another lesson.

Attribute names (like path, ensure, etc.) are special keywords, not strings. They shouldn’t be quoted.

Also, note that Puppet lets you use whatever whitespace makes your manifests more readable. We suggest visually lining up the => arrows, because it makes it easier to understand a manifest at a glance. (The Vim plugins on the Learning Puppet VM will do this automatically as you type.)

For troubleshooting and validate manifest (*.pp) file, you can run :

puppet parser validate test.pp

or you can install puppet-lint (http://puppet-lint.com/) for help as well.

Third, find out if there are any hidden characters to make the trouble.

BMW
  • 42,880
  • 12
  • 99
  • 116
2

The error:

Error: Could not parse for environment production

is always followed by another error, for example:

  • Syntax error at 'x': expected 'x' at manifest.pp:123

    Which could indicate a missing comma.

  • Could not match at manifest.pp:123

    which could indicate a missing bracket.

So you should check the file at the specific line where the error is reported to see if the previous line has missing any commas or brackets (which is the most common mistake for that kind of error).

kenorb
  • 155,785
  • 88
  • 678
  • 743
1

This Error also appears when the host has a duplicate entry in nodes.pp file. In case there are multiple host in the file, please make sure there is single entry for a host.

Karan
  • 13
  • 2
0

Also check for missing quotation marks immediately before the point at which Puppet reports the error.

Christian Long
  • 10,385
  • 6
  • 60
  • 58