Retire dsa-is-shutdown-scheduled in favor of test -e /run/systemd/shutdown/scheduled
[mirror/dsa-puppet.git] / modules / debian_org / manifests / init.pp
index af8f8bb..be1fe71 100644 (file)
@@ -6,20 +6,17 @@ class debian_org {
        include debian_org::apt
 
        if $systemd {
-               include systemd
+               include dsa_systemd
                $servicefiles = 'present'
        } else {
                $servicefiles = 'absent'
        }
 
-       # the virtual facter needs virt-what on jessie to work
-       if versioncmp($::lsbmajdistrelease, '9') < 0 {
-               package { 'virt-what': ensure => installed }
-       } else {
-               package { 'virt-what': ensure => purged }
-       }
+       # the virtual facter needs virt-what on jessie to work; clean up.
+       package { 'virt-what': ensure => purged }
 
        $samhain_recipients = hiera('samhain_recipients')
+       $root_mail_alias = hiera('root_mail_alias')
 
        package { [
                        'klogd',
@@ -40,29 +37,19 @@ class debian_org {
                ensure => installed,
                tag    => extra_repo,
        }
-       file { '/etc/ssh/ssh_known_hosts':
-               ensure  => present,
-               replace => false,
-               mode    => '0644',
-               source  => 'puppet:///modules/debian_org/basic-ssh_known_hosts'
-       }
 
-       if versioncmp($::lsbmajdistrelease, '8') >= 0 {
-               $rubyfs_package = 'ruby-filesystem'
-       } else {
-               $rubyfs_package = 'libfilesystem-ruby1.9'
-       }
        package { [
                        'apt-utils',
                        'bash-completion',
                        'dnsutils',
                        'less',
                        'lsb-release',
-                       $rubyfs_package,
+                       'ruby-filesystem',
                        'mtr-tiny',
                        'nload',
                        'pciutils',
                        'lldpd',
+                       'ncurses-term',
                ]:
                ensure => installed,
        }
@@ -85,13 +72,6 @@ class debian_org {
                ]:
        }
 
-       if getfromhash($site::nodeinfo, 'broken-rtc') {
-               package { 'fake-hwclock':
-                       ensure => installed,
-                       tag    => extra_repo,
-               }
-       }
-
        package { 'molly-guard':
                ensure => installed,
        }
@@ -131,12 +111,13 @@ class debian_org {
                content => template('debian_org/debian_facts.yaml.erb')
        }
        file { '/etc/timezone':
-               source => 'puppet:///modules/debian_org/timezone',
+               content => "Etc/UTC\n",
                notify => Exec['dpkg-reconfigure tzdata -pcritical -fnoninteractive'],
        }
-       if $::hostname == handel {
-               include puppetmaster::db
-               $dbpassword = $puppetmaster::db::password
+       file { '/etc/localtime':
+               ensure => 'link',
+               target => '/usr/share/zoneinfo/Etc/UTC',
+               notify => Exec['dpkg-reconfigure tzdata -pcritical -fnoninteractive'],
        }
        file { '/etc/puppet/puppet.conf':
                content => template('debian_org/puppet.conf.erb'),
@@ -178,7 +159,27 @@ class debian_org {
        }
 
        file { '/etc/cron.d/dsa-puppet-stuff':
-               content => template('debian_org/dsa-puppet-stuff.cron.erb'),
+               ensure => 'absent',
+       }
+       file { '/etc/dsa/cron.ignore.dsa-puppet-stuff':
+               ensure => 'absent',
+       }
+
+       concat { '/etc/cron.d/puppet-crontab': }
+       concat::fragment { 'puppet-crontab---header':
+               target => '/etc/cron.d/puppet-crontab',
+               order  => '000',
+               content  => @(EOF)
+                       ## THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE.
+                       SHELL=/bin/bash
+                       MAILTO=root
+                       PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/nagios/plugins
+                       | EOF
+       }
+       concat::fragment { 'puppet-crontab---all':
+               target => '/etc/cron.d/puppet-crontab',
+               order  => '010',
+               content => template('debian_org/puppet-crontab.cron.erb'),
                require => Package['debian.org'],
        }
        file { '/etc/ldap/ldap.conf':
@@ -202,12 +203,12 @@ class debian_org {
                ensure => directory,
                mode   => '0755',
        }
-       file { '/etc/dsa/cron.ignore.dsa-puppet-stuff':
-               source  => 'puppet:///modules/debian_org/dsa-puppet-stuff.cron.ignore',
+       file { '/etc/dsa/cron.ignore.puppet-crontab':
+               source  => 'puppet:///modules/debian_org/puppet-crontab.cron.ignore',
                require => Package['debian.org']
        }
        file { '/etc/nsswitch.conf':
-               mode   => '0755',
+               mode   => '0444',
                source => 'puppet:///modules/debian_org/nsswitch.conf',
        }
 
@@ -222,24 +223,32 @@ class debian_org {
                mode   => '0444',
                source => 'puppet:///modules/debian_org/etc.zsh/zprofile',
        }
+       file { '/etc/environment':
+               content => "",
+               mode => '0440',
+       }
+       file { '/etc/default/locale':
+               content => "",
+               mode => '0444',
+       }
 
        # set mmap_min_addr to 4096 to mitigate
        # Linux NULL-pointer dereference exploits
-       site::sysctl { 'mmap_min_addr':
+       base::sysctl { 'mmap_min_addr':
                ensure => absent
        }
-       site::sysctl { 'perf_event_paranoid':
+       base::sysctl { 'perf_event_paranoid':
                key   => 'kernel.perf_event_paranoid',
                value => '2',
        }
-       site::sysctl { 'puppet-vfs_cache_pressure':
+       base::sysctl { 'puppet-vfs_cache_pressure':
                key   => 'vm.vfs_cache_pressure',
                value => '10',
        }
-       site::alternative { 'editor':
+       base::alternative { 'editor':
                linkto => '/usr/bin/vim.basic',
        }
-       site::alternative { 'view':
+       base::alternative { 'view':
                linkto => '/usr/bin/vim.basic',
        }
        mailalias { 'samhain-reports':
@@ -247,6 +256,11 @@ class debian_org {
                recipient => $samhain_recipients,
                require   => Package['debian.org']
        }
+       mailalias { 'root':
+               ensure    => present,
+               recipient => $root_mail_alias,
+               require   => Package['debian.org']
+       }
 
        file { '/usr/local/bin/check_for_updates':
                source => 'puppet:///modules/debian_org/check_for_updates',
@@ -255,8 +269,7 @@ class debian_org {
                group  => root,
        }
        file { '/usr/local/bin/dsa-is-shutdown-scheduled':
-               source  => 'puppet:///modules/debian_org/dsa-is-shutdown-scheduled',
-               mode    => '0555',
+               ensure => 'absent',
        }
 
        exec { 'dpkg-reconfigure tzdata -pcritical -fnoninteractive':
@@ -310,9 +323,60 @@ class debian_org {
                source => 'puppet:///modules/debian_org/root-dotfiles/vimrc',
        }
 
-       if versioncmp($::lsbmajdistrelease, '9') >= 0 { # older puppets do facts as strings.
+       if versioncmp($::lsbmajdistrelease, '9') == 0 { # older puppets do facts as strings.
                if $::processorcount > 1 {
                        package { 'irqbalance': ensure => installed }
                }
+       } else {
+               # 926967 drops the recommendation on irqbalance in Buster
+               package { 'irqbalance': ensure => purged }
+       }
+
+
+       # https://www.decadent.org.uk/ben/blog/bpf-security-issues-in-debian.html
+       base::sysctl { 'unprivileged_bpf_disabled':
+               key   => 'kernel.unprivileged_bpf_disabled',
+               value => '1',
+       }
+
+       # our ipv6 addresses and routes are statically configured.
+       base::sysctl { 'dsa-accept-ra-default':
+               key   => 'net.ipv6.conf.default.accept_ra',
+               value => 0,
+       }
+       base::sysctl { 'dsa-accept-ra-all':
+               key   => 'net.ipv6.conf.all.accept_ra',
+               value => 0,
+       }
+
+       # Disable kpartx udev rules
+       file { '/etc/udev/rules.d/60-kpartx.rules':
+               ensure => $has_lib_udev_rules_d_60_kpartx_rules ? { true  => 'present', default => 'absent' },
+               content => "",
+               mode => '0444',
+       }
+
+       # this is only to avoid warnings, else puppet will complain that we
+       # have a symlink there, even if we're not replacing it anyhow.
+       if ! $has_etc_ssh_ssh_known_hosts {
+               file { '/etc/ssh/ssh_known_hosts':
+                       ensure  => 'present',
+                       replace => 'no',
+                       content => inline_template('<%= open("/etc/ssh/ssh_known_hosts").read() %>'),
+                       notify  => Exec['ud-replicate'],
+               }
+       }
+
+       exec { 'ud-replicate':
+               path => '/usr/bin:/usr/sbin:/bin:/sbin',
+               command => '/usr/bin/ud-replicate',
+               refreshonly => true,
+               require => Package['userdir-ldap']
+       }
+
+       # some changes require rebuilding the initramfs.  Have the common exec here.
+       exec { 'update-initramfs -u':
+               path        => '/etc/init.d:/usr/bin:/usr/sbin:/bin:/sbin',
+               refreshonly => true;
        }
 }