2014-07-22 30 views
0

我敢肯定我在做一些愚蠢的事情,但我無法找出stdlib keys() function的正確語法,並且在互聯網上找不到任何示例。傀儡stdlib鍵()函數語法錯誤

這裏是我試過:

file { ["/tmp/file1", "/tmp/file2"]: # <-- this works as expected 
    ensure => present, 
} 

$hash = {"/tmp/file1" => 1, "/tmp/file2" => 2} 
file { keys($hash):     # <-- syntax error occurs here 
    ensure => present, 
} 

它導致這個錯誤:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Syntax error at ':'; expected '}' at /etc/puppet/modules/slony/manifests/master.pp:113 on node slonymaster

我缺少什麼?我在stdlib 4.3.2中使用Puppet 3.6.2。

回答

1

你只是壓榨你的表情。這個想法很有道理,但你必須採取中間步驟。

$filenames = keys($hash) 
file { $filenames: ensure => present } 

Puppet只接受字面數組值或變量作爲資源標題。

+0

這樣做的伎倆,謝謝! – aco