如何从模块获取 puppet 清单中的文件
我正在尝试从 puppet 清单中的本地模块获取文件(在独立模式下使用 puppet):
file {
'/home/repowt/.crontab':
ensure => present,
source => 'puppet:///modules/site/crontab';
}
但我得到:
Could not evaluate: Could not retrieve information from source(s) ...
文件位于:
config/puppet/modules/site/files/crontab
(puppet 通过 vagrant 配置
调用,并且 Vagrantfile 指定 module_path= 'config/puppet/modules' 显然没问题,因为 puppet 确实从那里加载了导入模块。)
我也尝试过:
source => 'puppet:///site/crontab'
source => 'site/crontab'
source => 'config/puppet/modules/site/files/crontab'
source => '/modules/site/crontab'
无济于事。我在网上找不到任何有启发性的东西,看起来很简单。 感谢您的帮助。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这里发生了一些事情。
首先,正如 pwan 所说,
fileserver.conf
需要正确设置。请记住,
/vagrant
包含Vagrantfile
所在的目录(以及所有内容),这对我来说意味着:我的
fileserver.conf 指定要使用
/etc/puppet/files
。虽然我可以为 Vagrant 指定不同的
fileserver.conf
,但我希望几乎所有内容都与正常情况相同。因此,我也安装了
/etc/puppet/files
,这让事情对我有用。
There are a couple of things going on here.
First, as pwan notes, the
fileserver.conf
needs to be setup correctly.Keeping in mind that
/vagrant
contains the directory whereVagrantfile
is (and therefore all of it content), that meant for me doing:My
fileserver.conf
specifies that/etc/puppet/files
is to be used.Whilst I could have specified a different
fileserver.conf
, just for Vagrant, I wanted pretty much everything to be the same as normal.So, I also mounted
/etc/puppet/files
too, withWhich got things working for me.
puppet:///modules/my_module/file
应匹配%vagrant_root%/modules/my_module/files/file
puppet:///modules/my_module/file
should match%vagrant_root%/modules/my_module/files/file
我注意到 Vagrant 在目标虚拟机上安装了其目录的副本(我正在使用 base http://dl.dropbox.com/u/15307300/vagrant-0.7-centos-64-base.box);做一个“安装”,看看你是否也有这个。
这允许我在 Vagrant 中创建一个目录,与清单/平行,我称之为“files/”。然后我将配置源文件放在那里,例如.../myvagrantproject/files/slapd.conf。这在虚拟机上显示为 /vagrant/files/slapd.conf
然后在文件源的 puppet 清单中,我将源列为绝对文件路径,而不是 puppet 服务器路径,例如:
它发现它没有问题来自它自己的 vbox -挂载远程文件系统。
I noticed that Vagrant mounted a copy of its dir on the target VM (I'm using base http://dl.dropbox.com/u/15307300/vagrant-0.7-centos-64-base.box); do a "mount" and see if you have this too.
This allows me to create a directory within my Vagrant, parallel to manifests/ that I call "files/". I then put my config source file under there, e.g., .../myvagrantproject/files/slapd.conf. This appears on the VM as /vagrant/files/slapd.conf
Then in the puppet manifest for the file source I list the source as an absolute file path, not a puppet server path, like:
It found it no problemmo from it's own vbox-mounted remote filesystem.
您原来的 puppet://modules/site/crontab 应该可以工作。
我怀疑您的 puppetmaster 上的 fileserver.conf 可能没有模块部分。如果尚不存在,请尝试添加如下所示的内容。
请查看 http://docs.puppetlabs.com/guides/modules 中的“模块查找”部分。 html
Your original puppet://modules/site/crontab should work.
I suspect the fileserver.conf on your puppetmaster may not have a modules section. Try adding something like below if it's not already present.
Check out the 'Module Lookup' section at http://docs.puppetlabs.com/guides/modules.html
从您的描述中不清楚您是在独立模式还是在客户端-服务器模式下使用木偶。
假设您使用的是独立模式,请仔细检查虚拟机中的 /tmp 文件夹,看看模块文件夹是否确实存在并且 vagrant 已安装它。
您可以加载清单这一事实并不意味着模块也在那里。
您的原始配置看起来正确。
It is not clear from your description if you are using the puppet in standalone mode or in client-server mode.
Assuming that you are using the standalone mode, double check in your /tmp folder in your vm to see if the module folder is actually there and vagrant has mounted it.
The fact that you can load the manifest, doesn't mean that the modules are there as well.
Your original configuration, looks correct.