I think I understand what you are driving at, and your logic seems good to me. When I was doing web hosting for people I had a class that handled installing and configuring Apache and a separate module called "sites" that handled setting up the web sites using the apache::vhost define that contained the logic to set up a VirtualHost definition file and create the DocRoot directory.
The difference was I was using templates and synthesizing the configuration file based on some parameters passed to the define. HTH. On Mon, Jul 20, 2015 at 12:18 PM Fabien Delpierre < [email protected]> 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/puppet-users/6e3e084d-700d-4d84-ba89-0e27524aec3d%40googlegroups.com > <https://groups.google.com/d/msgid/puppet-users/6e3e084d-700d-4d84-ba89-0e27524aec3d%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CAArvnv28c%2By4qGw4vMsnU9j6fXOfumBUEmmZ8jwm5hEq8KkjAg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
