我想知道如何建立:datadir:
在hiera.yaml
与日伪和流浪最佳利用。目前,我在运行木偶3.1.1的Ubuntu 12.04来宾上,在Ubuntu 13.10上将vagrant 1.5.0与virtualbox 4.2一起使用
我正在尝试建立一个类似于此博客文章Puppet最佳实践:特定于环境的配置的环境。具体来说,我的Vagrantfile包含:
config.vm.define "servername" do |servername|
servername.vm.box = "precise-puppet-3"
servername.vm.network "private_network", ip: "192.168.213.2",
virtualbox__intnet: "networkname"
# Provision with puppet.
servername.vm.provision :puppet do |puppet|
puppet.hiera_config_path = "puppet/hiera.yaml"
puppet.manifests_path = "puppet/manifests"
puppet.module_path = "puppet/modules"
puppet.manifest_file = "servername.pp"
puppet.facter = {
"vagrant" => "1",
"server" => "servername",
}
end
end
我可以确认hiera_config_path
正确,因为如果删除,则会出现错误hiera.yaml
。
puppet/hiera.yaml
包含:
---
:backends: yaml
:yaml:
:datadir: "manifests/configuration"
:hierarchy:
- "%{::clientcert}"
- "%{::environment}"
- "virtual_%{::is_virtual}"
- common
:logger: console
而且,进一步puppet/manifests/configuration/common.yaml
包含:
---
myvar: "test"
从命令行进行测试:
$ hiera -c hiera.yaml myvar
test
到现在为止还挺好。但是,如果我尝试从up清单文件中进行测试,则找不到该变量,并且会出现错误。测试示例:
$myvariable = hiera(myvar)
notice("My variable is: ${myvar}")
错误是:
Error: Could not find data item myvar in any Hiera data file and no default supplied at...
如果通过ssh进入计算机vagrant ssh
,则可以看到Vagrant正在将清单文件挂载在/ tmp / vagrant-puppet-2。如果我编辑hiera.yaml
文件,并:datadir:
用完整路径替换/tmp/vagrant-puppet-2/manifests/configuration
,那么我的Puppet清单可以访问我的Hiera数据。我可以使用相对路径吗?
hiera.yaml
文件,一个用于vagrant,一个用于Puppet(在生产中)?