Puppet无法解析环境错误

时间:2015-01-24 01:05:06

标签: puppet

我目前遇到以下错误:

Error: Could not parse for environment production: Syntax error at end of file on node master.domain.org

尝试运行以下木偶代码时

puppet apply --parser future -e '$vars={ 
  0 => '192.1.1.140', 
  1 => '192.1.1.141', 
  2 => '192.1.1.142', 
} each($vars) |$id,$gate| { notice "${id} -> ${gate}" }'

奇怪的是,我可以毫无问题地运行它,

puppet apply --parser future -e '$vars={ 
  0 => '1.0', 
  1 => '1.1', 
  2 => '1.2', 
} each($vars) |$id,$gate| { notice "${id} -> ${gate}" }'

Notice: Scope(Class[main]): 0 -> 1.0
Notice: Scope(Class[main]): 1 -> 1.1
Notice: Scope(Class[main]): 2 -> 1.2
Notice: Compiled catalog for master.domain.org in environment production in 0.33 seconds
Notice: Finished catalog run in 0.01 seconds

我认为它是第二个(和第三个)点的东西,我该如何解决这个问题?

修改

我正在做更多的测试并注意到这个小宝石

puppet apply --parser future -e '$ip='1.1-1' $vars={ 
  0 => "${ip}.0", 
  1 => "${ip}.1", 
  2 => "${ip}.2", 
} each($vars) |$id,$gate| { notice "${id} -> ${gate}" }'

Notice: Scope(Class[main]): 0 -> 0.10000000000000009.0
Notice: Scope(Class[main]): 1 -> 0.10000000000000009.1
Notice: Scope(Class[main]): 2 -> 0.10000000000000009.2
Notice: Compiled catalog for master.domain.org in environment production in 0.34 seconds
Notice: Finished catalog run in 0.02 seconds

看起来它做了一些奇怪的数学扩展/解释?

1 个答案:

答案 0 :(得分:1)

在这种情况下,您需要使用双引号。

puppet apply --parser future -e '$vars={ 
  0 => "192.1.1.140", 
  1 => "192.1.1.141", 
  2 => "192.1.1.142", 
} each($vars) |$id,$gate| { notice "${id} -> ${gate}" }'