Potential bug in logrotate module when shorthand configuration used.

20 views
Skip to first unread message

Steve Scotter

unread,
Oct 29, 2024, 12:56:45 PM10/29/24
to Salt-users
Hi,
I was looking into a diskspace / syslog issue today and executed the following command to see how logrotate was configured for the auth.log file

salt 'COMPUTERNAME' logrotate.get /var/log/auth.log rotate /etc/logrotate.d/syslog-ng

It failed with 

[ERROR   ] An un-handled exception was caught by Salt's global exception handler:
AttributeError: 'bool' object has no attribute 'get'

Here's what /etc/logrotate.d/syslog-ng looks like

# cat /etc/logrotate.d/syslog-ng
/var/log/syslog
{
        rotate 7
        daily
        missingok
        notifempty
        delaycompress
        compress
        postrotate
                invoke-rc.d syslog-ng reload > /dev/null
        endscript
}

/var/log/mail.info
/var/log/mail.warn
/var/log/mail.err
/var/log/mail.log
/var/log/daemon.log
/var/log/kern.log
/var/log/auth.log
/var/log/user.log
/var/log/lpr.log
/var/log/cron.log
/var/log/debug
/var/log/messages
/var/log/error
{
        rotate 4
        weekly
        missingok
        notifempty
        compress
        delaycompress
        sharedscripts
        postrotate
                invoke-rc.d syslog-ng reload > /dev/null
        endscript
}

If I try again, but for syslog or error it works.

salt 'COMPUTERNAME' logrotate.get /var/log/syslog rotate /etc/logrotate.d/syslog-ng
COMPUTERNAME:
    7

salt 'COMPUTERNAME' logrotate.get /var/log/error rotate /etc/logrotate.d/syslog-ng
COMPUTERNAME:
    4


But not for messages...

salt 'COMPUTERNAME' logrotate.get /var/log/messages rotate /etc/logrotate.d/syslog-ng
COMPUTERNAME:
    The minion function caused an exception: Traceback (most recent call last):
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/minion.py", line 1969, in _thread_return
        return_data = minion_instance._execute_job_function(
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/minion.py", line 1925, in _execute_job_function
        return_data = self.executors[fname](opts, data, func, args, kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 160, in __call__
        ret = self.loader.run(run_func, *args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1269, in run
        return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1284, in _run_as
        return _func_or_method(*args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/executors/direct_call.py", line 10, in execute
        return func(*args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 160, in __call__
        ret = self.loader.run(run_func, *args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1269, in run
        return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1284, in _run_as
        return _func_or_method(*args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/logrotate.py", line 161, in get
        return stanza.get(value, False)
    AttributeError: 'bool' object has no attribute 'get'
ERROR: Minions returned with non-zero exit code

This leads me to think the module doesn't like the shortcut logrotate configuration of stacking multiple files before the opening curly brace.

Anyone else getting this? Just trying to gauge if it's worth logging a bug on github.

Thanks

Steve

Steve Scotter

unread,
Oct 29, 2024, 1:02:35 PM10/29/24
to Salt-users
Just clocked there's a logrotate.show_conf. When I execute that it simply returns True for auth.log, which seems to confirm my suspicions. 

# salt 'COMPUTERNAME' logrotate.show_conf
COMPUTERNAME  :
    ----------
    /var/log/alternatives.log:
        ----------
        compress:
            True
        create:
            644 root root
        delaycompress:
            True
        missingok:
            True
        monthly:
            True
        notifempty:
            True
        rotate:
            12
    /var/log/apport.log:
        ----------
        compress:
            True
        daily:
            True
        delaycompress:
            True
        missingok:
            True
        notifempty:
            True
        rotate:
            7
    /var/log/apt/history.log:
        ----------
        compress:
            True
        missingok:
            True
        monthly:
            True
        notifempty:
            True
        rotate:
            12
    /var/log/apt/term.log:
        ----------
        compress:
            True
        missingok:
            True
        monthly:
            True
        notifempty:
            True
        rotate:
            12
    /var/log/aptitude:
        ----------
        compress:
            True
        missingok:
            True
        monthly:
            True
        notifempty:
            True
        rotate:
            6
    /var/log/auth.log:
        True
    /var/log/boot.log:
        ----------
        copytruncate:
            True
        daily:
            True
        missingok:
            True
        notifempty:
            True
        rotate:
            7
    /var/log/btmp:
        ----------
        create:
            0660 root utmp
        missingok:
            True
        monthly:
            True
        rotate:
            1
    /var/log/cloud-init*.log:
        ----------
        compress:
            True
        delaycompress:
            True
        missingok:
            True
        nocreate:
            True
        notifempty:
            True
        rotate:
            6
        size:
            1M
        su:
            root root
    /var/log/cron.log:
        True
    /var/log/daemon.log:
        True
    /var/log/debug:
        True
    /var/log/dpkg.log:
        ----------
        compress:
            True
        create:
            644 root root
        delaycompress:
            True
        missingok:
            True
        monthly:
            True
        notifempty:
            True
        rotate:
            12
    /var/log/error:
        ----------
        compress:
            True
        delaycompress:
            True
        endscript:
            True
        invoke-rc.d:
            syslog-ng reload > /dev/null
        missingok:
            True
        notifempty:
            True
        postrotate:
            True
        rotate:
            4
        sharedscripts:
            True
        weekly:
            True
    /var/log/kern.log:
        True
    /var/log/lpr.log:
        True
    /var/log/mail.err:
        True
    /var/log/mail.info:
        True
    /var/log/mail.log:
        True
    /var/log/mail.warn:
        True
    /var/log/messages:
        True
    /var/log/salt/api:
        ----------
        compress:
            True
        create:
            640
        missingok:
            True
        notifempty:
            True
        rotate:
            7
        weekly:
            True
    /var/log/salt/key:
        ----------
        compress:
            True
        create:
            640
        missingok:
            True
        notifempty:
            True
        rotate:
            7
        weekly:
            True
    /var/log/salt/master:
        ----------
        compress:
            True
        create:
            640
        missingok:
            True
        notifempty:
            True
        rotate:
            7
        weekly:
            True
    /var/log/salt/minion:
        ----------
        compress:
            True
        create:
            640
        missingok:
            True
        notifempty:
            True
        rotate:
            7
        weekly:
            True
    /var/log/salt/proxy:
        ----------
        compress:
            True
        create:
            640
        missingok:
            True
        notifempty:
            True
        rotate:
            7
        weekly:
            True
    /var/log/salt/syndic:
        ----------
        compress:
            True
        create:
            640
        missingok:
            True
        notifempty:
            True
        rotate:
            7
        weekly:
            True
    /var/log/squid/*.log:
        ----------
        compress:
            True
        daily:
            True
        delaycompress:
            True
        endscript:
            True
        missingok:
            True
        nocreate:
            True
        postrotate:
            True
        prerotate:
            True
        rotate:
            2
        sharedscripts:
            True
        test:
            ! -e /run/squid.pid || test ! -x /usr/sbin/squid || /usr/sbin/squid -k rotate
    /var/log/sssd/*.log:
        ----------
        compress:
            True
        delaycompress:
            True
        endscript:
            True
        kill:
            -HUP `cat /var/run/sssd.pid` > /dev/null 2>&1 || true
        missingok:
            True
        notifempty:
            True
        postrotate:
            True
        rotate:
            4
        weekly:
            True
    /var/log/stunnel4/*.log:
        ----------
        /etc/init.d/stunnel4:
            reopen-logs > /dev/null
        compress:
            True
        create:
            640 stunnel4 stunnel4
        daily:
            True
        delaycompress:
            True
        endscript:
            True
        missingok:
            True
        notifempty:
            True
        postrotate:
            True
        rotate:
            365
        sharedscripts:
            True
    /var/log/syslog:
        ----------
        compress:
            True
        daily:
            True
        delaycompress:
            True
        endscript:
            True
        invoke-rc.d:
            syslog-ng reload > /dev/null
        missingok:
            True
        notifempty:
            True
        postrotate:
            True
        rotate:
            7
    /var/log/tinyproxy/tinyproxy.log:
        ----------
        compress:
            True
        daily:
            True
        endscript:
            True
        invoke-rc.d:
            --quiet tinyproxy reload > /dev/null
        missingok:
            True
        notifempty:
            True
        postrotate:
            True
        rotate:
            14
    /var/log/unattended-upgrades/unattended-upgrades-dpkg.log:
        True
    /var/log/unattended-upgrades/unattended-upgrades-shutdown.log:
        ----------
        compress:
            True
        missingok:
            True
        monthly:
            True
        notifempty:
            True
        rotate:
            6
    /var/log/unattended-upgrades/unattended-upgrades.log:
        True
    /var/log/user.log:
        True
    /var/log/wtmp:
        ----------
        create:
            0664 root utmp
        minsize:
            1M
        missingok:
            True
        monthly:
            True
        rotate:
            1
    /var/log/zabbix/zabbix_agentd.log:
        ----------
        compress:
            True
        create:
            0640 zabbix zabbix
        delaycompress:
            True
        missingok:
            True
        notifempty:
            True
        rotate:
            12
        weekly:
            True
    create:
        True
    include:
        /etc/logrotate.d
    include files:
        ----------
        alternatives:
            - /var/log/alternatives.log
        apport:
            - /var/log/apport.log
        apt:
            - /var/log/apt/term.log
            - /var/log/apt/history.log
        aptitude:
            - /var/log/aptitude
        bootlog:
            - /var/log/boot.log
        btmp:
            - /var/log/btmp
        cloud-init:
            - /var/log/cloud-init*.log
        dpkg:
            - /var/log/dpkg.log
        salt-common:
            - /var/log/salt/master
            - /var/log/salt/minion
            - /var/log/salt/key
            - /var/log/salt/api
            - /var/log/salt/syndic
            - /var/log/salt/proxy
        squid:
            - /var/log/squid/*.log
        sssd-common:
            - /var/log/sssd/*.log
        stunnel4:
            - /var/log/stunnel4/*.log
        syslog-ng:
            - /var/log/syslog
            - /var/log/mail.info
            - /var/log/mail.warn
            - /var/log/mail.err
            - /var/log/mail.log
            - /var/log/daemon.log
            - /var/log/kern.log
            - /var/log/auth.log
            - /var/log/user.log
            - /var/log/lpr.log
            - /var/log/cron.log
            - /var/log/debug
            - /var/log/messages
            - /var/log/error
        tinyproxy:
            - /var/log/tinyproxy/tinyproxy.log
        unattended-upgrades:
            - /var/log/unattended-upgrades/unattended-upgrades.log
            - /var/log/unattended-upgrades/unattended-upgrades-dpkg.log
            - /var/log/unattended-upgrades/unattended-upgrades-shutdown.log
        wtmp:
            - /var/log/wtmp
        zabbix-agent:
            - /var/log/zabbix/zabbix_agentd.log
    rotate:
        4
    su:
        root adm
    weekly:
        True


Phipps, Thomas

unread,
Oct 29, 2024, 1:18:39 PM10/29/24
to salt-...@googlegroups.com
thank you for tracking that down. please put in a ticket at https://github.com/saltstack/salt/issues

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/salt-users/f2882a48-d0b1-4a7a-a492-920daa3dba75n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages