Ask Your Question
0

Trouble with file resource using array of sources

asked 2015-08-27 03:04:18 -0600

cm01 gravatar image

updated 2015-08-28 00:34:12 -0600

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 flag offensive close merge delete

Comments

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.

ramindk gravatar imageramindk ( 2015-08-28 11:12:25 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-08-27 12:30:17 -0600

ramindk gravatar image

updated 2015-08-27 23:44:17 -0600

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
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-08-27 03:04:18 -0600

Seen: 196 times

Last updated: Aug 28 '15