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 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?

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.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Reply via email to