How to source a file in puppet manifest from module

Viktor Trón picture Viktor Trón · Aug 27, 2011 · Viewed 26.1k times · Source

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.

Answer

akumria picture akumria · May 5, 2012

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.