Manage Amavisd Service

264 views
Skip to first unread message

jochen....@gmail.com

unread,
Nov 24, 2023, 6:46:28 AM11/24/23
to Puppet Users
Hi,

I manage a Debian Mailserver running postfix, amavis and others. I have service statements in place that should keep the server running.

From time to time, the service resource does not correctly restart the amavis service.

if I do service amavis status, the output should be

   Active: active (running)

but it seems to me, when the output is

   Active: active (exited)

my service resource does not work:

service { 'amavis':
        ensure => running
}

active(exited) is the typical state a running postfix is in... I don't know, why this does not seem to work with amavis. Can anyone please share some knowledge how to correctly keep amavis running?

Thanks, best
Jochen

jochen....@gmail.com

unread,
Nov 24, 2023, 6:51:07 AM11/24/23
to Puppet Users
Perhaps I should add, that manually a

service amavis start 

also did not solve the problem, but a

service amavis restart

helped. The Active state again changed to active(running)

Kenyon Ralph

unread,
Nov 25, 2023, 4:16:11 PM11/25/23
to Puppet Users
This is a problem with amavis, not puppet. You'll need to do systemctl status amavis, journalctl --pager-end --unit amavis, and look at amavis's own logs to see why the service is dying or not starting.

Jochen Haeberle

unread,
Nov 26, 2023, 7:13:37 AM11/26/23
to puppet...@googlegroups.com


Am 25.11.2023 um 22:16 schrieb 'Kenyon Ralph' via Puppet Users <puppet...@googlegroups.com>:


This is a problem with amavis, not puppet. You'll need to do systemctl status amavis, journalctl --pager-end --unit amavis, and look at amavis's own logs to see why the service is dying or not starting.

The service restarts manually fine with service amavis restart

The question is not why it died but how to get it running again using Puppet.

Kenyon Ralph

unread,
Nov 27, 2023, 11:54:21 AM11/27/23
to Puppet Users
 Puppet simply runs systemctl start amavis if you have ensure => running. If it is dying, it most likely has nothing to do with Puppet.

Jochen Haeberle

unread,
Nov 28, 2023, 6:45:26 AM11/28/23
to puppet...@googlegroups.com


Am 27.11.2023 um 17:54 schrieb 'Kenyon Ralph' via Puppet Users <puppet...@googlegroups.com>:

The service restarts manually fine with service amavis restart

The question is not why it died but how to get it running again using Puppet.

 Puppet simply runs systemctl start amavis if you have ensure => running. If it is dying, it most likely has nothing to do with Puppet.

sure, Puppet is not involved in the dying. But my problem is, why it is not restarting the service. When I had the problem, 

service amavis start did not work, but service amavis restart did. So I changed my declaration to

service { 'amavis':
        hasrestart => true,
        ensure => running
}

Perhaps this will work better. 

Jochen Haeberle

unread,
Dec 1, 2023, 12:39:58 PM12/1/23
to puppet...@googlegroups.com
now I have a declaration that kicks in when the problem occurs:

service { 'amavis':
        hasrestart => true,
        provider => 'systemd',
        restart => '/usr/sbin/service amavis restart',
        status => '/usr/bin/systemctl is-active --quiet amavis && [ "$(/usr/bin/systemctl show -p SubState --value amavis)" = "running" ] && exit 0 || exit 1',
        ensure => running
}


the status-line detects the problem fine and when I run this, puppet says it’s chaning the service status:

Notice: /Stage[main]/Main/Service[amavis]/ensure: ensure changed 'stopped' to 'running'

But it is not running after that. Manually running  

/usr/sbin/service amavis restart

brings up the service fine.

Anyone has a tipp what I am doing wrong?

thx

Nick Bertrand

unread,
Dec 1, 2023, 1:11:16 PM12/1/23
to puppet...@googlegroups.com
Hi Jochen,

When amavis is in the broken state, does `service amavis start` fix it or is it just `service amavis restart` that fixes it? If 'restart' works, but 'start' doesn't, I wonder if Puppet is running the start command instead of restart. Running the puppet agent in debug mode should show you the actual command being run. If you see `systemctl start amavis` is being run, you might try setting the `start` parameter to what you have `restart` set to:

service { 'amavis':
...
        start => '/usr/sbin/service amavis restart',
...
}

Thanks,

Nick

--
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/BD107A9D-ED3E-46F9-9A29-CF9D62FB4D94%40gmail.com.

Jochen Haeberle

unread,
Dec 1, 2023, 1:17:29 PM12/1/23
to puppet...@googlegroups.com
Hi Nick,

good point! As of the debug log, it seems to issue the start command, although the dog says that puppet would use the restart command if hasrestart is set to true

I will have to wait for the problem to reoccur to finally test this. Thanks a lot

Kenyon Ralph

unread,
Dec 1, 2023, 2:02:56 PM12/1/23
to Puppet Users
On Friday, December 1, 2023 at 10:17:29 AM UTC-8 jochen....@gmail.com wrote:
Hi Nick,

good point! As of the debug log, it seems to issue the start command, although the dog says that puppet would use the restart command if hasrestart is set to true

I will have to wait for the problem to reoccur to finally test this. Thanks a lot

 This is not a puppet problem. Your amavis service configuration is broken if it requires a restart instead of a start when it dies and is stopped. Either fix the service, or use puppet to install a systemd dropin that sets https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html#Restart= or something like that.
Reply all
Reply to author
Forward
0 new messages