Puppet 无法解析环境错误

Puppet could not parse environment error

我目前运行遇到以下错误:

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

我假设它与第二个(和第三个)点有关,我该如何解决这个问题?

编辑

我正在做更多测试并注意到这个小东西 gem

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

看起来它在做一些奇怪的数学运算 expansion/interpretation?

看来在这种情况下,你需要使用双引号。

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}" }'