如何修复'Could not parse for environment production'错误?



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

err:无法解析环境生产:无法在/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 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-lint (http://puppet-lint.com/) 寻求帮助。

第三,找出是否有隐藏的人物来制造麻烦。

错误:

错误:无法分析环境生产

总是跟着另一个错误,例如:

  • "x"处

    的语法错误:清单处的预期"x".pp:123

    这可能表示缺少逗号。

  • 无法在清单上匹配.pp:123

    这可能表示缺少括号。

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

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

还要检查 Puppet 报告错误的点之前是否缺少引号。

最新更新