On Mon, Jan 11, 2010 at 1:06 PM, Jesús Couto <jesus.co...@gmail.com> wrote:
> Hi. I'm trying to do a test/proof of concept of Puppet as a tool to manage > our systems. > > In our enviroment we have several different instances of apache running on > each "webserver" machine, and several instances of tomcat running in our > "appservers" machines > > I'm trying to duplicate that structure using Puppet on a Ubuntu machine I'm > using for testing, to no avail yet. > > Isnt any well know recipe to do this? Or at least an idea about how to go > to achieve it? > > So far what I've done is this: > > - Define a class webserver that ensures the apache package is installed and > NOT running, and creates a directory for the instances info to be stored > > class webserver { > case $operatingsystem { > ubuntu: { $web_packages = "apache2" } > } > > package { $web_packages: ensure => installed } > > service { httpd: > name => $operatingsystem ? { > ubuntu => "apache2", > }, > ensure => stopped, > enable => false, > } > file {"/etc/webinstances/": > ensure => directory, > owner => root, > group => root, > mode => 755, > } > } > > - Include that class into a definition of "webinstance" that tries to > populate the directory of that instance from the puppet fileserver, and > start/stop a "base" service provider with a script generated from a > template: > > define webinstance(owner,group,ensure = running) { > include webserver > file { "/etc/webinstances/$name/": > owner => $owner, > group => $group, > mode => 600, > ensure => directory, > recurse => true, > source => "puppet:///webinstances/$name/", > } > file { "/usr/sbin/start_$name.sh": > owner => root, > group => root, > mode => 700, > content => template("start_instance.erb"), > > } > file { "/usr/sbin/stop_$name.sh": > owner => root, > group => root, > mode => 700, > content => template("stop_instance.erb"), > } > service { "$name": > ensure => $ensure, > provider => base, > start => "/usr/sbin/start_$name.sh", > stop => "/usr/sbin/stop_$name.sh", > status => "/usr/sbin/apache2 -f > /etc/webinstances/$name/apache2.conf -k sta > rt", > require => [ > File["/etc/webinstances/$name"],File["/usr/sbin/start_$name.sh > "],File["/usr/sbin/stop_$name.sh"] ], > } > } > > - every node that needs to have an instance will define it > > node staberinde { > webinstance { "uno": > owner => root, > group => root, > ensure => running, > } > webinstance { "dos": > owner => root, > group => root, > ensure => running, > } > } > > ... but appart from not getting the scripts to start & stop the instances > (it says the scripts "return 1" although I can run them from the prompt > without problem: > > err: //Node[staberinde]/Webinstance[uno]/Service[uno]/ensure: change from > stopped to running failed: Could not start Service[uno]: Execution of > '/usr/sbin/start_uno.sh' returned 1: at > /etc/puppet/manifests/webinstance-definition.pp:31 > > the start and stop params take a command, not a file. (just like status) You are executing the filename as a command, which will return 1. If you want to use a file, then use a file to create custom init scripts, in redhat (and I think on Debian, it looks like this) file { "/etc/init.d/$name": owner => root, group => root, mode => 700, content => template("start_instance.erb"), } service{$name ensure => running, status => "/usr/sbin/apache2 -f /etc/webinstances/$name/ > > apache2.conf -k sta > rt", > require => [ > File["/etc/webinstances/$name"],File["/usr/sbin/start_$name.sh > "],File["/etc/init.d/$name."] ], } the script woudl have to be a little different (ie: take stop and start as arguments like regular init script) > ... the other thing that is making me think this is convoluted and wrong > is... what if I want the same instance in 2 nodes, as we do? can I use the > definition on both nodes with the same parameters and not get an error cause > I'm defining the same resource twice? > You can specify the same resources on multiple nodes. Resources must be unique per compiled catalog. Only resources for a certain host will be compiled into its catalog. > > Best regards, > > ------------------------------ > > Jesús Couto F. > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To post to this group, send email to puppet-us...@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscr...@googlegroups.com<puppet-users%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet-us...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.