I created a custom fact that determines what class of server it is based 
off the first 3 letters of the hostname: tst, qa, stg, prd, dev.... The 
fact tested fine and shows in the list when running "facter -p". I wanted 
to use the fact in a class to determine if zabbix-agent should be removed 
or installed. I want to remove from servers that currently have zabbix 
installed in groups tst, dev and qa. For some reason this doesn't work at 
all. It doesn't error out but doesn't do anything. Every time I run puppet 
or even debug it just finishes like nothing has changed. Can you please 
tell me what I'm doing wrong? My test machine is in the 'tst' server class 
so in theory puppet should more the zabbix-agent package. Thanks - Chris


class zabbix {

        class client {
    $module_name = "zabbix"

    if $datacenter == 'boston' {
        $zabbix_server = 'yoda.enernoc.net'}
    else {
        $zabbix_server = 'vader.enernoc.net'}

# Determine server class. Remove agent from qa, tst and dev server classes
if (( $server_class == 'qa[a-z0-9]' ) or ( $server_class == 'tst' )  or  ( 
$server_class == 'dev' )) {

                        package { "zabbix-agent":
                        ensure   => absent,
                        }}
        else {
                        package { "zabbix-agent":
                        ensure   => installed,
                        }

                        etmpl { "/etc/zabbix/zabbix_agentd.conf":
                        group   => "zabbix",
                        mode    => 0640,
                        require => Package["zabbix-agent"]}}

    # The following files are empty and are only used for the Zabbix
    # vfs.fs.writable check.
    $zabbix_files = [ "/.zabbix_writable",
                      "/var/.zabbix_writable",
                      "/opt/.zabbix_writable",
                      "/home/.zabbix_writable",]

    efile { $zabbix_files:
      owner   => "zabbix",
      require => Package["zabbix-agent"],
    }

                service { "zabbix-agent":
                        enable    => true,
                        hasstatus => true,
                        ensure    => running,
                        require   => [ 
Etmpl["/etc/zabbix/zabbix_agentd.conf"] ],
                        }
        } # zabbix::client

} # zabbix

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-users/-/yqqWjFVZg78J.
To post to this group, send email to puppet-users@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