web-dev-qa-db-ja.com

「環境本番用に解析できませんでした」エラーを修正する方法は?

これが私の小さな人形スニペットです:このスニペットを実行すると、次のエラーが発生しました:

エラー:環境の本番環境を解析できませんでした:/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,
    }
}

誰かが指摘するのを手伝ってくれませんか?

7
James Sapam

エラーCould not parse for environment productionについては、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.)

マニフェスト(* .pp)ファイルのトラブルシューティングと検証のために、以下を実行できます。

puppet parser validate test.pp

または、puppet-linthttp://puppet-lint.com/ )をインストールしてヘルプを表示することもできます。

第三に、問題を起こす隠されたキャラクターがいないか調べます。

9
BMW

エラー:

エラー:環境の本番環境を解析できませんでした

常に別のエラーが続きます。次に例を示します。

  • 'x'での構文エラー:manifest.pp:123で予期される 'x'

    カンマがないことを示している可能性があります。

  • マニフェスト.pp:123で一致しませんでした

    角かっこがないことを示している可能性があります。

したがって、エラーが報告された特定の行のファイルをチェックして、前の行にコンマまたは角かっこがないかどうかを確認する必要があります(これはこの種のエラーの最も一般的な間違いです)。

2
kenorb

このエラーは、ホストのnodes.ppファイルに重複するエントリがある場合にも表示されます。ファイルに複数のホストがある場合は、ホストのエントリが1つであることを確認してください。

1
Karan

また、Puppetがエラーを報告する直前に引用符がないかどうかを確認します。

0
Christian Long