Figured it out! The issue was not with my Puppet code, but simply with my 
Vagrantfile.

I had the following:

config.vm.provision :puppet do |puppet|
  puppet.manifests_path = "manifests"
  puppet.module_path = "modules"
  puppet.working_directory = "/vagrant"
  puppet.facter = {
  }
end

I edited the third line like so:

config.vm.provision :puppet do |puppet|
  puppet.manifests_path = "manifests"
  puppet.module_path = ["..", "modules"]
  puppet.working_directory = "/vagrant"
  puppet.facter = {
  }
end

And now, using source => 'puppet:///modules/sensei/mysite.conf' is working 
fine. Makes sense!



On Monday, July 20, 2015 at 12:17:56 PM UTC-4, Fabien Delpierre wrote:
>
> Hi folks,
> I'm super new to Puppet but decently experienced with Chef, I'm trying to 
> apply my Chef logic to some things I'm trying to do in Puppet but I've hit 
> what is probably a simple snag. And perhaps I shouldn't be trying to apply 
> Chef logic, but hear me out first!
>
> Firstly, I'm following along John Arundel's book, *Puppet 3 Beginner's 
> Guide*. It's had me create a module to do my own things, as well as a 
> separate module that just installs Nginx, and now it's trying to set up a 
> basic website by providing a virtual host file and writing it to 
> /etc/nginx/sites-enabled. The way it's having me do that is to invoke the 
> file resource directly from within my nginx class/module. I know that 
> will work, but that seems like heresy.
>
> In my Chef logic, I would create a cookbook just to set up my website, 
> have it invoke an external cookbook to install Nginx, and then simply drop 
> the Nginx config file in the right spot, like so:
>
> include_recipe "nginx::default"
>
> cookbook_file "/var/www/mysite/index.html"
> cookbook_file "/etc/nginx/sites-enabled/mysite.conf"
>
> That separates the process of just installing Nginx (which my simpleton 
> Nginx class is doing just fine) from setting up the website. 
>
> What I have so far in Puppet looks like this:
>
> mysite
> -files
> --mysite.conf
>
> -manifests
> --default.pp
> --nodes.pp
>
> -modules
> --nginx
> ---manifests
> ----init.pp
>
> The book wants me to add a files directory under nginx and put the 
> mysite.conf there. But in my logic, the nginx class is an external 
> dependency -- or at least, going forward, I would actually use the 
> "official" Nginx module and call it from my custom module somehow, so 
> assuming the Nginx module is its own entity that I cannot change, I'd have 
> to find a way to write mysite.conf directly from my custom module.
>
> My nodes.pp looks like this:
>
> node 'sensei-debian7' {
>
>   include nginx
>
>   file { "/var/www/mysite/index.html":
>     content => "Hello?\n",
>   }
>
>   file { ["/var/www", "/var/www/mysite"]:
>     ensure => directory
>   }
>
>   file { "/etc/nginx/sites-enabled/default":
>     source => 'puppet:///sensei/mysite.conf',
>     notify => Service['nginx'],
>   }
> }
>
> That source attribute above is my problem. sensei is the name of my 
> learning module. I'm using Vagrant for testing, and when I run vagrant 
> provision, Puppet complains that it cannot find the path:
> ==> debian7: Error: 
> /Stage[main]/Main/Node[sensei-debian7]/File[/etc/nginx/sites-enabled/default]:
>  
> Could not evaluate: Could not retrieve information from environment 
> production source(s) puppet:///sensei/mysite.conf
>
> Like I said, the book would like me to put the mysite.conf in 
> modules/nginx/files/mysite.conf and have the following source line:
> source => 'puppet:///modules/nginx/mysite.conf',
> I'm sure that that would work, but since it feels wrong to do it that way, 
> I'm trying to write that line correctly so that it fetches the mysite.conf 
> directly from my module, without going to the Nginx module at all. 
> I've tried multiple things:
> puppet:///modules/sensei/mysite.conf
> puppet:///sensei/mysite.conf
> puppet:///files/mysite.conf (I figured that wouldn't work since I 
> understand Puppet adds the files/ in those instances)
> puppet:///mysite.conf 
> and others. But nothing works.
>
> I hope this makes sense. 
> So, I don't know if I'm going about this all wrong or if I just need to 
> find the right syntax for that source line. If this is all wrong, then 
> what's the right way of doing it?
> Let's assume that, later on, I might move my Nginx module to its own Git 
> repo and invoke it from my Sensei module using a Puppetfile/Librarian.
>
> Thanks for reading, and any pointers would be appreciated!
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/17162ca7-cee8-4f41-a877-7604bae6aede%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to