Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agent service needs to require the startup script #788

Closed
baron1405 opened this issue Sep 13, 2021 · 8 comments · Fixed by #794
Closed

Agent service needs to require the startup script #788

baron1405 opened this issue Sep 13, 2021 · 8 comments · Fixed by #794
Labels
bug Something isn't working

Comments

@baron1405
Copy link

The agent service does not explicitly require the startup script. This can result in the agent service starting using the wrong systemd service configuration file. The specific case causing the issue is:

Operating system: CentOS 7.7
Zabbix agent version: Default in the module

The zabbix agent RPM installs a systemd service script in /usr/lib/systemd/system. Because the Service['zabbix-agent'] does not require the Systemd::Unit_File['zabbix-agent.service'] in startup.pp, the service configuration file in /usr/lib/systemd/system is used rather than the correct one in /etc/systemd/system. The results in the service not completing its startup and being left in an undefined state (i.e. "starting" according to systemd).

I was able to work around the problem by telling the agent module not to manage the startup script, installing the startup script in my manifest and having the zabbix::agent require the startup script.

class zabbix_agent {
    include systemd
    
    systemd::unit_file { 'zabbix-agent.service':
        source => 'puppet:///modules/zabbix_agent/zabbix-agent.service',
        path   => '/etc/systemd/system',
    }

    class { 'zabbix::agent':
        server                => 'nn.nn.nn.nnn',
        manage_startup_script => false,
        require               => Systemd::Unit_File['zabbix-agent.service'],
    }
}
@smortex
Copy link
Member

smortex commented Sep 13, 2021

As far as I can recall, this dependency is automatically managed by Puppet. What version are you using?

@baron1405
Copy link
Author

I am using Puppet 6.22.1 and puppet-zabbix 9.1.0.

@root-expert
Copy link
Member

Hey @baron1405 ! Can you take a look at the zabbix::startup class. I believe that can solve your problem (although dunno how obvious/usable is that).

@baron1405
Copy link
Author

@root-expert thanks for the reply. Yes, I looked at zabbix::startup while investigating this bug. I believe the problem is that where zabbix::agent defines the service resource (line 316) it does not require either the zabbix::startup resource (line 297) or the file resource it creates. Obviously, the startup resource is in an if so the appropriate variable for the require would have to be defined with an undef in the case where managing the startup script is false. I imagine an alternative approach would be for the systemd::unit_file in zabbix::startup (line 47) to perform a notify to the service. Either way, an ordering should be established so that the agent service runs against the module installed systemd service conf (in /etc/systemd/system) rather than the conf file installed by the zabbix-agent package (in /usr/lib/systemd/system).

Note that before arriving at the above workaround where I manage the startup script, I tried using arrow notation to have the service class depend on the systemd unit file resource. It did not work but that could be either due to my clumsiness with Puppet or the relationship not being interpreted when or as expected.

@root-expert
Copy link
Member

What's your version of puppet/systemd?

@baron1405
Copy link
Author

@root-expert Versions are:

Puppet: 6.22.1
puppet-zabbix: 9.1.0
CentOS: 7.6
Systemd: 219

@root-expert
Copy link
Member

Sorry it wasn't very clear, I was asking what's your version of puppet-systemd module 😅

@baron1405
Copy link
Author

puppet-systemd: 3.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants