parts of class being skipped :(

28 views
Skip to first unread message

kaseeve

unread,
Oct 4, 2017, 12:36:52 PM10/4/17
to Puppet Users

Please forgive my limited knowledge on puppet. I need some assistance in achieving what most of you would consider a very simple task. I am attempting to install zabbix agent below and modify the configuration file then reload the service. I believe the code is incomplete but i am not sure where the problem is because the agent run in not generating an error. from analysis the package is installed and the service is enabled then nothing else.

My thought process for the class is a follow. 1.Create a repo on the servers 2. install zabbix agent 3. modify the config file 4. reload the service.

The code can be seen below. Thank you in advance for any assistance i really appreciate it.

class zabbixinstall {
case $operatingsystemmajrelease {
        "5": {
                yumrepo { 'zabbix3.4_repo':
                enabled  => 1,
                descr    => 'Zabbix 3.4 Repo Created by Sysad',
                baseurl  => 'http://repo.zabbix.com/zabbix/3.4/rhel/5/$basearch/',
                gpgcheck => 1,
                gpgkey   => 'http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX',
                         }
                }
        "6": {
                yumrepo { 'zabbix3.4_repo':
                enabled  => 1,
                descr    => 'Zabbix 3.4 Repo Created by Sysad',
                baseurl  => 'http://repo.zabbix.com/zabbix/3.4/rhel/6/$basearch/',
                gpgcheck => 1,
                gpgkey   => 'http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX',
                         }
                }
        "7": {
                yumrepo { 'zabbix3.4_repo':
                enabled  => 1,
                descr    => 'Zabbix 3.4 Repo Created by Sysad',
                baseurl  => 'http://repo.zabbix.com/zabbix/3.4/rhel/7/$basearch/',
                gpgcheck => 1,
                gpgkey   => 'http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX',
                         }
                }
        }


        package { 'zabbix-agent':
        ensure  => 'installed',
        require => Yumrepo['zabbix3.4_repo'],
  }
        service { 'zabbix-agent':
        enable => 'true',
        ensure  => running,
        require => Package['zabbix-agent']
        }

        file_line{ 'Append a line to /etc/zabbix/zabbix_agentd.conf':
                path    => '/etc/zabbix/zabbix_agentd.conf',
                line    => "Server=server2.grp.local",
                ensure  => 'present',
                match   => '^Server\=127\.0\.0\.1',
                append_on_no_match  => 'false',
                 }
        file_line{ 'Replace line to /etc/zabbix/zabbix_agentd.conf':
                path    => '/etc/zabbix/zabbix_agentd.conf',
                line    => "ServerActive=server2.grp.local",
                ensure  => 'present',
                match   => '^ServerActive\=127\.0\.0\.1',
                append_on_no_match  => 'false',
                 }


}

Lowe Schmidt

unread,
Oct 4, 2017, 1:47:31 PM10/4/17
to puppet...@googlegroups.com
What is the problem you’re having?

Sent from my iPhone
--
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 puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/1c8f121b-9ed0-4a4d-8cbf-7f79b3f77c21%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jcbollinger

unread,
Oct 5, 2017, 9:14:01 AM10/5/17
to Puppet Users
It's suspicious to me that you have resources managing parts of /etc/zabbix/zabbix_agentd.conf, but nothing in your manifest to specify that they should be applied before Service['zabbix-agent'] is managed, or to make the service take notice if those are applied when it is already running.  Moreover, you have nothing to specify that that file should be managed after Package['zabbix-agent'], which I presume will provide the base version of that file.

Regardless of your actual problem, I would think that any way around, your two File_line resources both need to declare relationships with those other resources:

  require => Package['zabbix-agent'],
  notify  
=> Service['zabbix-agent']

Perhaps that will even constitute a complete solution.

As a completely separate issue, your great big case statement is confusing and wasteful.  The only difference between the three cases is the release-number component of the repository path, which you have in the form of a variable that you know about already.  Your manifest could be substantially DRYed out by replacing the whole case statement to simply this:

  yumrepo { 'zabbix3.4_repo':
    enabled  
=> 1,
    descr    
=> 'Zabbix 3.4 Repo Created by Sysad',

    baseurl  
=> "http://repo.zabbix.com/zabbix/3.4/rhel/${operatingsystemmajrelease}/\$basearch/",

    gpgcheck
=> 1,
    gpgkey  
=> 'http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX',
 
}

Note use of a double-quoted string to permit the $operatingsystemmajrelease variable to be interpolated, and the escaping of the '$' to prevent "$basearch" from being interpreted as a Puppet variable reference.


John

Reply all
Reply to author
Forward
0 new messages