Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix 'Could not parse for environment production' error?

Tags:

puppet

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?

like image 492
James Avatar asked Dec 12 '14 23:12

James


1 Answers

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.

like image 199
BMW Avatar answered Nov 25 '22 16:11

BMW