I though i found a way to do it, and i would like to show it here,
but unfortunately it does not exactly work well, see the comment in
uppercase: global variables seems to be set even if no class from
the .pp file is included.
   And i also think now i am going to far into akwardness, just trying
to work around some Puppet limitations, or maybe thinking of Puppet
beyond its scope, as if it was a full featured language
   I am wondering now if it is always a good idea to try to do
everything within Puppet. I think if i get time, i will do a generic
script to address this problem, which would be deployed with the usual
set of scripts i deploy on each server, and run it from Puppet. I also
recently went onto another set of Puppet problem, to which i began
implementing a define to do some processing, and ended up having this
define only get the parameters and give it all to a deployed script
that does the processing (just because i needed to loop on the items
of a puppet array).

   Anyway, here was my last, and almost working to get the default
stripdown (shows relevant parts) :

##
## mysqld.pp
##

# This variable is global, not defined inside the class, otherwise it
will never be seen as set, due to the dynamic scope
$_service_is_managed_mysqld=1
class mysql::server inherits mysql {
# (...)
}


##
## stripdown.pp
##

define stripdown_service ( $pattern="" ) {

    if $pattern == "" {
        exec { "stripdown $name stop":
                command => "service $name stop",
                onlyif  => "service $name status",
                path    => "/usr/bin:/usr/sbin:/bin:/sbin",
            }
    } else {
        exec { "stripdown $name stop":
                command => "service $name stop",
                onlyif  => "pgrep -f \"$name\"",
                path    => "/usr/bin:/usr/sbin:/bin:/sbin",
            }
    }

    exec { "stripdown $name deactivate":
        command => "chkconfig $name off",
        onlyif  => "chkconfig $name",
        path    => "/usr/bin:/usr/sbin:/bin:/sbin",
    }
}

class stripdown_services::centos {
    service {
        "autofs": enable => "false", ensure => "stopped";
        "avahi-daemon": enable => "false", ensure => "stopped";
# (...)
    }

# THIS $_service_is_managed_xxx THING DOES NOT WORK : EVEN IF NOT
CLASS NOT INCLUDED IN THE NODE, THE VARIABLE SEEMS TO BE SET !!!

    if $_service_is_managed_squid != 1 { stripdown_service{squid:} }
    if $_service_is_managed_lighttpd != 1 { stripdown_service
{lighttpd: pattern=>"lighttpd.conf"} }
    if $_service_is_managed_mysqld != 1 { stripdown_service{mysqld:} }
# (...)
}


--

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