defaults = {
    'pacman': {
        'ask_before_removal': {
            'glibc',
            'pacman',
        },
        'no_extract': {
            'etc/cron.d/0hourly',
            # don't install systemd-homed pam module. It produces a lot of spam in
            # journal about systemd-homed not being active, so just get rid of it.
            # Requires reinstall of systemd package, though
            'usr/lib/security/pam_systemd_home.so',
        },
        'parallel_downloads': 4,
        'repository': 'http://ftp.uni-kl.de/pub/linux/archlinux/$repo/os/$arch',
        'unattended-upgrades': {
            'day': 5,
            'hour': 21,
        },
    },
}


@metadata_reactor.provides(
    'cron/jobs/upgrade-and-reboot',
    'icinga2_api/pacman/services',
)
def patchday(metadata):
    if not metadata.get('pacman/unattended-upgrades/is_enabled', False):
        return {}

    day = metadata.get('pacman/unattended-upgrades/day')
    hour = metadata.get('pacman/unattended-upgrades/hour')

    return {
        'cron': {
            'jobs': {
                'upgrade-and-reboot': '{minute} {hour} * * {day}    root    /usr/local/sbin/upgrade-and-reboot'.format(
                    minute=node.magic_number % 30,
                    hour=hour,
                    day=day,
                ),
            },
        },
        'icinga2_api': {
            'pacman': {
                'services': {
                    'UNATTENDED UPGRADES': {
                        'command_on_monitored_host': '/usr/local/share/icinga/plugins/check_unattended_upgrades',
                    },
                },
            },
        },
    }