【问题标题】:Puppet stdlib keys() function syntax errorPuppet stdlib keys() 函数语法错误
【发布时间】:2014-09-12 15:53:15
【问题描述】:

我确定我在做一些愚蠢的事情,但我无法为stdlib keys() function 找出正确的语法,并且在互联网上找不到任何示例。

这是我尝试过的:

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,
}

这会导致这个错误:

错误:无法从远程服务器检索目录:错误 400 on 服务器:“:”处的语法错误;预期 '}' 在 /etc/puppet/modules/slony/manifests/master.pp:113 在节点 slonymaster 上

我错过了什么?我将 Puppet 3.6.2 与 stdlib 4.3.2 一起使用。

【问题讨论】:

    标签: puppet


    【解决方案1】:

    你只是在过度使用你的表达方式。这个想法是合理的,但你必须采取中间步骤。

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

    Puppet 只接受文字数组值或变量作为资源标题。

    【讨论】:

      猜你喜欢
      • 2014-02-11
      • 2017-12-15
      • 2016-11-02
      • 1970-01-01
      • 2021-06-26
      • 1970-01-01
      • 1970-01-01
      • 2018-08-21
      • 2014-11-26
      相关资源
      最近更新 更多