如何从模块获取 puppet 清单中的文件

发布于 2024-12-01 20:49:13 字数 916 浏览 2 评论 0 原文

我正在尝试从 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'

无济于事。我在网上找不到任何有启发性的东西,看起来很简单。 感谢您的帮助。

I am trying to source files from local modules in a puppet manifest (using puppet in standalone mode):

file {
  '/home/repowt/.crontab':
    ensure => present,
    source => 'puppet:///modules/site/crontab';
}

but I get:

Could not evaluate: Could not retrieve information from source(s) ...

The file is in:

config/puppet/modules/site/files/crontab

(puppet is called via vagrant provision and the Vagrantfile specifies module_path='config/puppet/modules' and is clearly ok since puppet does load modules with import from there.)

I also tried:

source => 'puppet:///site/crontab'
source => 'site/crontab'
source => 'config/puppet/modules/site/files/crontab'
source => '/modules/site/crontab'

of no avail. I found nothing illuminating on the web, seems like something very simple.
your help is appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

○愚か者の日 2024-12-08 20:49:13

这里发生了一些事情。

首先,正如 pwan 所说,fileserver.conf 需要正确设置。

请记住,/vagrant 包含 Vagrantfile 所在的目录(以及所有内容),这对我来说意味着:

vm_config.vm.provision :puppet, :module_path => "modules", :options => ["--fileserverconfig=/vagrant/fileserver.conf", ]

我的 fileserver.conf 指定要使用 /etc/puppet/files

虽然我可以为 Vagrant 指定不同的 fileserver.conf,但我希望几乎所有内容都与正常情况相同。

因此,我也安装了 /etc/puppet/files

vm_config.vm.share_folder "files", "/etc/puppet/files", "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 where Vagrantfile is (and therefore all of it content), that meant for me doing:

vm_config.vm.provision :puppet, :module_path => "modules", :options => ["--fileserverconfig=/vagrant/fileserver.conf", ]

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, with

vm_config.vm.share_folder "files", "/etc/puppet/files", "files"

Which got things working for me.

|煩躁 2024-12-08 20:49:13

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

过度放纵 2024-12-08 20:49:13

我注意到 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 服务器路径,例如:

file { 'slapd.conf':
  name          => '/etc/openldap/slapd.conf',
  ensure        => present,
  source        => '/vagrant/files/slapd.conf',
  owner         => root,
  group         => ldap,
  mode          => 0640,
  require       => Package["ldapservers"],
}

它发现它没有问题来自它自己的 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:

file { 'slapd.conf':
  name          => '/etc/openldap/slapd.conf',
  ensure        => present,
  source        => '/vagrant/files/slapd.conf',
  owner         => root,
  group         => ldap,
  mode          => 0640,
  require       => Package["ldapservers"],
}

It found it no problemmo from it's own vbox-mounted remote filesystem.

维持三分热 2024-12-08 20:49:13

您原来的 puppet://modules/site/crontab 应该可以工作。

我怀疑您的 puppetmaster 上的 fileserver.conf 可能没有模块部分。如果尚不存在,请尝试添加如下所示的内容。

[modules]
    allow *

请查看 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.

[modules]
    allow *

Check out the 'Module Lookup' section at http://docs.puppetlabs.com/guides/modules.html

一身仙ぐ女味 2024-12-08 20:49:13

从您的描述中不清楚您是在独立模式还是在客户端-服务器模式下使用木偶。
假设您使用的是独立模式,请仔细检查虚拟机中的 /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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文