2

I've tried to google this, but haven't had any luck. My goal is to have a packaged directory with a puppet file and an accompanying directory holding file resources where I can just type puppet apply setup.pp and then puppet will do its thing.

I know that puppet's recommended workflow is to create modules and place the file resources there for copying. This is too inconvenient for me, as I don't want to have to install my modules there; I just want to be able to carry around this small package (i.e. pp file and file resources).

How can I configure my pp file to look into my sibling directory if I don't want to use absolute paths? Are there other environment variables I can manipulate to force puppet to look "in the right place"?

I saw a suggestion here that looks like it's extending Facter, but I'm just looking for something to put at the top of my pp file like this:

$basepath = exec{"/usr/bin/pwd":}

...

file {"/home/$title/.nanorc": source => "${basepath}/resources/.nanorc"}
Son of the Wai-Pan
  • 727
  • 4
  • 11
  • 25

1 Answers1

1

Puppet is just Ruby under the hood. I would try to use the inline_template function:

file{"/home/$title/.nanorc":
  content => inline_template("<%= File.read(ENV["PWD"] + '/resources/.nanorc') %>"),
}
  • I tried this (I'm trying to copy an entire directory): `source => inline_template("<%= ENV['PWD'].to_s + '/skel_dir/' %>")`. The error I get is this: `err: /Stage[main]//Student[test1]/File[/home/test1/]: Failed to generate additional resources using 'eval_generate: undefined method 'relative_path' for nil:NilClass err: /Stage[main]//Student[test1]/File[/home/test1/]: Could not evaluate: Could not retrieve information from environment production source(s) file:/skel_dir at /home/shared/puppet/crt_students.pp:15`. Do you know how I can resolve this? – Son of the Wai-Pan Jun 10 '13 at 06:16