# Trouble with file resource using array of sources

Hi Guys,

working on Puppet 3.8.1 Enterprise on Centos 6.7 if that helps.

My Master's dirs :

ls /etc/puppetlabs/puppet/files test.local test.vm4

ls /etc/puppetlabs/puppet/environments/production manifests modules

I am self teaching & I figured I'd work on the real thing at home..

I've got this section in my site.pp

file { "/tmp/test.file":
ensure => "present",
source => [
"puppet:///test.$hostname", "puppet:///test.$domain",
],
}


but when I try to use it I get:

puppet apply /etc/puppetlabs/puppet/environments/production/manifests/site.pp
Notice: Compiled catalog for puppet.local in environment production in 0.57 seconds
Error: /Stage[main]/Main/File[/tmp/test.file]: Could not evaluate: Could not retrieve file
metadata for puppet:///test.boole: Cannot find file: Invalid mount 'test.boole'


Obviously that file doesn't exist, but that's deliberate - I want it to fall through to the 2nd option and install that on the master. The first option will be installed on my test vm (I hope...).

I'm also really unclear as to which dir "puppet:///" points to...

Cheers
Chris

So, I tried the first soln below - no joy. If I put that code in the module's init.pp, it will 'apply' cleanly, but no file is created. If instead I make the init.pp empty and add the following to the site.pp, it works.

file { '/tmp/testing':
ensure => file,
source => [
##       "puppet:///testing/test.${::hostname}", ## "puppet:///testing/test.${::domain}",
"puppet:///modules/testing/test.$hostname", "puppet:///modules/testing/test.$domain",
],
}


I'm happy that the above works, but I'd like to know what the module specific init.pp would look like if I wanted to use that instead of the site.pp.

Cheers
Chris

Tried using 'include testing' in site.pp instead of the above and used class testing... code in the init.pp, but got

Error: /Stage[main]/Testing/File[/tmp/testing]: Could not evaluate: Could not retrieve information from environment production source(s) puppet:///testing/test.boole, puppet:///testing/test.local


update ok - so IF I explicitly add that include into both the default node stanza AND the vm4 node stanza, then it works in both cases.

QN: is there some sort of 'global' default area, so that I could have that include included by ALL nodes without having to specify it in all node stanzas? The duplication seems redundant, especially if you want to scale into eg 1000's of nodes.
Thx

edit retag close merge delete

This question is a getting a bit large. I'd recommend asking a new question for the information you want. I'd also recommend using the learning VM and starting with the docs which will walk you through all of this in a far less haphazard way.

( 2015-08-28 11:12:25 -0500 )edit

Sort by » oldest newest most voted

It's best to start using modules from the very beginning where your manifests, files, and templates are all contained within.

https://docs.puppetlabs.com/puppet/la...

In your example the files would be

modules/testing/manifests/init.pp
modules/testing/files/test.hostname1
modules/testing/files/test.domain


and the code would look like

class testing {

file { '/tmp/testing':
ensure => file,
source => [
"puppet:///testing/test.${::hostname}", "puppet:///testing/test.${::domain}",
],
}
}


In order to use the module you'll need to apply it to the node. It might look like to following.

site.pp

include testing

more