11

I'm using puppet as my provisioner in one of my vagrant project. I'm trying to add a module for a custom bash_profile.

The module_path for puppet is set to:

 puppet.module_path = "puppet/modules"

The class for my bash_profile module looks like this:

class bash_profile
{
    file
    {
        "/home/vagrant/bash_profile":
            ensure => present,
            source => "puppet:///modules/bash_profile/files/bash_profile"
    }
}

Here's the file structure for my puppet structure:

puppet
| manifests
| | phpbase.pp // my main manifest file that has includes for modules
| modules
| | bash_profile
| | | files
| | | | bash_profile // the actual bash_profile file I want to ensure is present on my VM
| | | manifests
| | | | init.pp // the init file included for the bash_profile class

When I run the provisioning for vagrant, I get the error

err: /Stage[main]/Bash_profile/File[/home/vagrant/bash_profile]: Could not evaluate: Could not retrieve information from environment production source(s) puppet:///modules/bash_profile/files/bash_profile at /tmp/vagrant-puppet-1/modules-0/bash_profile/manifests/init.pp:8

I'm not sure why it can't retrieve the information. The path seems to be correct. Can anyone see what I'm missing?

dertkw
  • 7,798
  • 5
  • 37
  • 45
Chris Schmitz
  • 20,160
  • 30
  • 81
  • 137
  • @timbooo, just curious, why did you edit the title? I prefix my questions that way so it's easier for me to look back through them later. – Chris Schmitz Jun 13 '14 at 21:16
  • It's not necessary to put tags into the title, see [this link](https://meta.stackexchange.com/questions/19190/should-questions-include-tags-in-their-titles). Tags could be used by you as well to go through your questions in a topic-related manner. – dertkw Jun 13 '14 at 21:43
  • Gotcha, thanks for the link and clarification. – Chris Schmitz Jun 13 '14 at 21:45

3 Answers3

25

Yes, you are not supposed to include the literal files/ in the URL. Instead, it should just be

puppet:///modules/bash_profile/bash_profile
Felix Frank
  • 8,125
  • 1
  • 23
  • 30
  • 3
    I just read the same documentation and missed the same point. Four hours trying to get that URL straight! I also tried using file URI's. My colleague said that in the source attribute you need to leave the "file:" off. Not sure about that, but it works for him. – Paul Chernoch Jul 03 '14 at 14:38
  • 5
    Geez, that definitely flies in the face of what I expect from paths. – Ehtesh Choudhury Sep 24 '14 at 22:58
1

You may also receive this error with recurse => true if your module name is invalid. For instance, if you have this module structure:

modules ├── my-example │   └── files │   └── example │   └── test.txt

and this resource:

file { "/tmp/example":
  ensure => directory,
  recurse => true,
  source => "puppet:///modules/my-example/example",
}

you'll get this error:

==> default: Info: Could not find filesystem info for file 'my-example/example' in environment production ==> default: Error: /Stage[main]/Main/Node[default]/File[/tmp/example]: Could not evaluate: Could not retrieve information from environment production source(s) puppet:///my-example/example

The fix is to rename the module—for instance, naming it my_example fixes it. The rules for module names are documented but easy to miss.

Phil Calvin
  • 5,077
  • 2
  • 41
  • 35
0

Things to care about

  1. The Puppet URI format puppet:///modules/name_of_module/filename
  2. The fileserver directory to be present in the module directory

This video is an shows step-by-step guide to resolve the error

anish
  • 6,884
  • 13
  • 74
  • 140