aboutsummaryrefslogtreecommitdiff
path: root/modules/base_configuration/manifests/init.pp
blob: 8b4dd376a0c2c6e0f428962c93bc671857a24022 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
class base_configuration (
  $hostname = undef,
  $username = "immae",
  $userid   = 1000
) {
  service { "sshd":
    ensure => "running",
    enable => true,
  }
  service { "systemd-networkd.socket":
    ensure => "running",
    enable => true,
  }
  service { "systemd-networkd":
    ensure => "running",
    enable => true,
  }

  unless empty($hostname) {
    class { 'systemd::hostname':
      hostname => $hostname
    }
  }

  user { "${username}:${userid}":
    name       => $username,
    uid        => $userid,
    ensure     => "present",
    groups     => "wheel",
    managehome => true,
    notify     => Exec["remove_password"]
  }

  exec { "remove_password":
    command     => "/usr/bin/chage -d 0 $username && /usr/bin/passwd -d $username",
    refreshonly => true
  }

  ssh_authorized_key { $username:
    name => "immae@immae.eu",
    user => $username,
    type => "ssh-rsa",
    key  => "AAAAB3NzaC1yc2EAAAADAQABAAABAQDi5PgLBwMRyRwzJPnSgUyRAuB9AAxMijsw1pR/t/wmxQne1O5fIPOleHx+D8dyZbwm+XkzlcJpgT0Qy3qC9J8BPhshJvO/tA/8CI/oS/FE0uWsyACH1DMO2dk4gRRZGSE9IuzDMRPlnfZ3n0tdsPzzv3GH4It/oPIgsvkTowKztGLQ7Xmjr5BxzAhXcIQymqA0U3XWHSdWvnSRDaOFG0PDoVMS85IdwlviVKLnV5Sstb4NC/P28LFfgvW8DO/XrOqujgDomqTmR41dK/AyrGGOb2cQUMO4l8Oa+74aOyKaB61rr/rJkr+wCbEttkTvgFa6zZygSk3edfiWE2rgn4+v"
  }

  class { 'sudo':
    config_file_replace => false
  }

  sudo::conf { 'wheel':
    priority => 10,
    content  => "%wheel ALL=(ALL) ALL"
  }

  class { 'ssh::server':
     storeconfigs_enabled => false,
     options => {
        'AcceptEnv'                       => undef,
        'X11Forwarding'                   => 'yes',
        'PrintMotd'                       => 'no',
        'ChallengeResponseAuthentication' => 'no',
        'Subsystem'                       => 'sftp /usr/lib/openssh/sftp-server',
     }
  }

  class { 'pacman':
    color     => true,
    usesyslog => true,
  }

  pacman::repo { 'multilib':
    order   => 15,
    include => '/etc/pacman.d/mirrorlist'
  }

  class { '::logrotate':
    manage_cron_daily => false,
    config => {
      rotate_every => 'week',
      rotate       => 4,
      create       => true,
      compress     => true,
      olddir       => '/var/log/old',
      tabooext     => "+ .pacorig .pacnew .pacsave",
    }
  }

  logrotate::rule { 'wtmp':
    path         => '/var/log/wtmp',
    rotate_every => 'month',
    create       => true,
    create_mode  => '0664',
    create_owner => 'root',
    create_group => 'utmp',
    rotate       => '1',
    minsize      => '1M',
  }
  logrotate::rule { 'btmp':
    path         => '/var/log/btmp',
    missingok    => true,
    rotate_every => 'month',
    create       => true,
    create_mode  => '0600',
    create_owner => 'root',
    create_group => 'utmp',
    rotate       => '1',
  }

  ensure_packages(["whois"], { 'install_options' => '--asdeps' })
  class { 'fail2ban':
    logtarget => 'SYSLOG',
    backend   => 'systemd'
  }
  fail2ban::jail { 'sshd':
    backend  => 'systemd',
    port     => 'ssh',
    filter   => 'sshd',
    maxretry => 10,
    bantime  => 86400,
    logpath  => '',
    order    => 10
  }
}