试图使用与流浪汉和木偶的hiera

时间:2015-01-30 11:01:07

标签: debian vagrant puppet hiera

所以我尝试使用hiera来改变我设置git user.name和user.email的方式。在我的流浪盒上。

我在default.pp

中有这个
git::config { 'user.name':
    value => hiera("github_username"),
}

git::config { 'user.email':
    value => hiera("github_email"),
}

在Vagrant文​​件中我有这个(在puppet选项中):

  

puppet.options =“ - hiera_config /vagrant/hieradata/hiera.yaml”

这似乎正确加载。我在该文件中的内容是:

---
:backends:
  - yaml
:hierarchy:
  - defaults
  - "%{clientcert}"
  - "%{environment}"
  - global
  - company

:yaml:
  :datadir:/vagrant/hieradata

现在在公司里面。我有:

github_username: 'antonio'
github_email: 'antonio@mail.com'

当我进行vagrant配置时,我收到以下错误消息:

==> debian_dev: Error: Error from DataBinding 'hiera' while looking up 'apache::apache_name': can't convert Symbol into Integer on node debian.dev
==> debian_dev: Wrapped exception:
==> debian_dev: can't convert Symbol into Integer
==> debian_dev: Wrapped exception:
==> debian_dev: can't convert Symbol into Integer
==> debian_dev: Error: Error from DataBinding 'hiera' while looking up 'apache::apache_name': can't convert Symbol into Integer on node debian.dev
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

我正在使用apache模块,但即使在默认的hiera.yaml(/etc/hiera.yaml中的那个),也没有apache :: apache_name的定义。

如果我没有在抱怨中将选项传递给puppet,则找不到hiera.yaml并且它将使用默认值。

关于如何解决此问题的任何想法或建议?

谢谢!

PS:我正在使用Vagrant 1.6.5和puppet 3.7.1运行Windows 7

1 个答案:

答案 0 :(得分:4)

更新你的hiera.yaml文件,以便datadir中有一个空格:

:yaml:
  :datadir: /vagrant/hieradata

为了帮助调试,我建议在Vagrantfile中添加详细和调试选项:

config.vm.provision "puppet" do |puppet|
  puppet.options = "--verbose --debug"
end

以下是您应该看到的错误datadir值:

$ vagrant provision
==> other: Running provisioner: puppet...
==> other: Running Puppet with default.pp...
==> other: stdin: is not a tty
==> other: Notice: Scope(Node[default]): -----
==> other: Debug: hiera(): Hiera YAML backend starting
==> other: Debug: hiera(): Looking up github_username in YAML     backend
==> other: Debug: hiera(): Looking for data source defaults
==> other: Debug: hiera(): Found github_username in defaults    

以下是您更新的datadir应该看到的内容:

$ vagrant provision
==> other: Running provisioner: puppet...
==> other: Running Puppet with default.pp...
==> other: stdin: is not a tty
==> other: Notice: Scope(Node[default]): -----
==> other: Debug: hiera(): Hiera YAML backend starting
==> other: Debug: hiera(): Looking up github_username in YAML     backend
==> other: Debug: hiera(): Looking for data source defaults
==> other: Debug: hiera(): Found github_username in defaults

这也应该有助于解释当hiera进行查找时如何找到值。