如何修复“无法解析环境生产”错误?

时间:2014-12-12 23:30:24

标签: puppet

这是我的小傀儡片段:当我执行此片段时,我收到以下错误:

  

错误:无法解析环境生成:无法匹配/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,
    }
}

有人可以帮忙指出吗?

4 个答案:

答案 0 :(得分:9)

关于错误Could not parse for environment production,您可以查看网址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.)

要进行故障排除和验证清单(* .pp)文件,您可以运行:

puppet parser validate test.pp

您也可以安装puppet-linthttp://puppet-lint.com/)寻求帮助。

第三,找出是否有任何隐藏的字符来解决问题。

答案 1 :(得分:2)

错误:

  

错误:无法解析环境生产

后面总是会出现另一个错误,例如:

  •   

    'x'处的语法错误:manifest.pp上的预期'x':123

    这可能表示缺少逗号。

  •   

    无法在manifest.pp:123

    中匹配

    可能表示缺少括号。

因此,您应该检查报告错误的特定行的文件,以查看前一行是否缺少任何逗号或括号(这是此类错误最常见的错误)。

答案 2 :(得分:1)

当主机在nodes.pp文件中有重复条目时,也会出现此错误。 如果文件中有多个主机,请确保主机有单个条目。

答案 3 :(得分:0)

同时检查Puppet报告错误之前的缺失引号。

相关问题