Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 758
Viktor Trón Avatar asked Aug 27 '11 18:08

Viktor Trón


People also ask

How do you use Puppet modules?

To create a module, you must create a directory (whose name matches your module name) in Puppet's modules directory, and it must contain a directory called manifests , and that directory must contain an init. pp file. The init. pp file must only contain a Puppet class that matches the module name.

How do you write a manifest file in Puppet?

In Puppet, all the programs which are written using Ruby programming language and saved with an extension of . pp are called manifests. In general terms, all Puppet programs which are built with an intension of creating or managing any target host machine is called a manifest.


1 Answers

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.

like image 101
akumria Avatar answered Oct 01 '22 07:10

akumria