1

所以我试图使用 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

现在在 company.yaml 我有:

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

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

==> 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

4

1 回答 1

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    

以下是更新数据目录后您应该看到的内容:

$ 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 进行查找时如何找到值。

于 2015-02-01T15:44:22.733 回答