How to source a file in puppet manifest from module
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.
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.
puppet:///modules/my_module/file
should match %vagrant_root%/modules/my_module/files/file
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.
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
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.
精彩评论