init.pp 6.75 KB
Newer Older
1
class datorhandbok {
Hugo Hörnquist's avatar
Hugo Hörnquist committed
2
3
  ensure_packages([
    'apache2', 
4
    'default-mysql-server',
Hugo Hörnquist's avatar
Hugo Hörnquist committed
5
6
7
8
9
    'mediawiki',
    'imagemagick',
    # squid is needed for pam_auth binary
    'squid3',
    ],
Hugo Hörnquist's avatar
Hugo Hörnquist committed
10
    { ensure => installed, })
Hugo Hörnquist's avatar
Hugo Hörnquist committed
11
12
13

  service { 'apache2':
    ensure    => running,
Hugo Hörnquist's avatar
Hugo Hörnquist committed
14
    enable    => true,
Hugo Hörnquist's avatar
Hugo Hörnquist committed
15
16
17
18
19
    require   => Package['apache2'],
  }

  service { 'mysql':
    ensure    => running,
Hugo Hörnquist's avatar
Hugo Hörnquist committed
20
    enable    => true,
21
    require   => Package['default-mysql-server'],
Hugo Hörnquist's avatar
Hugo Hörnquist committed
22
23
24
25
  }

  service { 'squid':
    ensure    => stopped,
Hugo Hörnquist's avatar
Hugo Hörnquist committed
26
    enable    => false,
Hugo Hörnquist's avatar
Hugo Hörnquist committed
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
    require   => Package['squid3'],
  }


  #  ┌───────────────────────────────┤ Configuring mariadb-server-10.1 ├───────────────────────────────┐
  #  │                                                                                                 │
  #  │ Important note for NIS/YP users                                                                 │
  #  │                                                                                                 │
  #  │ Using MariaDB under NIS/YP requires a mysql user account to be added on the local system with:  │
  #  │                                                                                                 │
  #  │  adduser --system --group --home /var/lib/mysql mysql                                           │
  #  │                                                                                                 │
  #  │                                                                                                 │
  #  │ You should also check the permissions and ownership of the /var/lib/mysql directory:            │
  #  │                                                                                                 │
  #  │  /var/lib/mysql: drwxr-xr-x   mysql    mysql                                                    │
  #  │                                                                                                 │
  #  │                                             <Ok>                                                │
  #  │                                                                                                 │
  #  └─────────────────────────────────────────────────────────────────────────────────────────────────┘
Hugo Hörnquist's avatar
Hugo Hörnquist committed
47
48
49
50
51
52
53
54
55
  # Mariadb gave the following notice on upgrade. Might as well
  # explicitly specifify it here

  group { 'mysql':
    ensure => present,
    system => true,
  }

  user { 'mysql':
Hugo Hörnquist's avatar
Hugo Hörnquist committed
56
    ensure     => present,
Hugo Hörnquist's avatar
Hugo Hörnquist committed
57
58
59
60
61
62
63
64
65
66
67
    system     => true,
    gid        => 'mysql',
    home       => '/var/lib/mysql',
  }

  file { '/var/lib/mysql':
    ensure => directory,
    owner  => mysql,
    group  => mysql,
    mode   => '0755',
  }
Hugo Hörnquist's avatar
Hugo Hörnquist committed
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

  cron { 'backup-mysql':
    command => 'TMPFILE=`/bin/mktemp /var/tmp/fulldump.sql.XXX` && /usr/bin/mysqldump --all-databases --events > "$      TMPFILE" && mv "$TMPFILE" /var/lib/mysql-dump/fulldump.sql',
    user    => 'root',
    hour    => 3,
    minute  => 11;

  }

  file { '/etc/apache2/mods-enabled/rewrite.load':
      ensure  => symlink,
      target  => '/etc/apache2/mods-available/rewrite.load',
      owner   => root,
      group   => root,
      notify  => Service['apache2'],
      require => Package['apache2'],
  }

  file { '/etc/apache2/mods-enabled/ssl.load':
      ensure  => symlink,
      target  => '/etc/apache2/mods-available/ssl.load',
      owner   => root,
      group   => root,
      notify  => Service['apache2'],
      require => Package['apache2'],
  }

  lyscert::letsencrypt { 'letsencrypt-certonly':
    email     => 'root@lysator.liu.se',
    webserver => 'apache2',
  }

  file { '/etc/apache2/sites-available/datorhandbok.lysator.liu.se.conf':
      ensure  => file,
      owner   => root,
      group   => root,
      mode    => '0444',
      notify  => Service['apache2'],
      require => Package['apache2'],
      content  => epp('datorhandbok/datorhandbok.lysator.liu.se',
        {
Hugo Hörnquist's avatar
Hugo Hörnquist committed
109
110
111
112
113
114
          # 'sslcertificatefile'      => '/etc/ssl/certs/datorhandbok.lysator.liu.se/datorhandbok.lysator.liu.se.pem',
          # 'sslcertificatekeyfile'   => '/etc/ssl/certs/datorhandbok.lysator.liu.se/datorhandbok.lysator.liu.se.key',
          # 'sslcertificatechainfile' => '/etc/ssl/certs/DigiCertCA.crt',
          'sslcertificatefile'      => "/etc/letsencrypt/live/${facts['networking']['fqdn']}/fullchain.pem",
          'sslcertificatekeyfile'   => "/etc/letsencrypt/live/${facts['networking']['fqdn']}/privkey.pem",
          'sslcertificatechainfile' => "/etc/letsencrypt/live/${facts['networking']['fqdn']}/fullchain.pem",
Hugo Hörnquist's avatar
Hugo Hörnquist committed
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
        }),
  }

  file { '/etc/apache2/sites-enabled/datorhandbok.lysator.liu.se.conf':
    ensure  => symlink,
    target  => '/etc/apache2/sites-available/datorhandbok.lysator.liu.se.conf',
    owner   => root,
    group   => root,
    notify  => Service['apache2'],
    require => File['/etc/apache2/sites-available/datorhandbok.lysator.liu.se.conf'],
  }

  file { '/etc/apache2/sites-enabled/000-default':
    ensure => absent,
    notify => Service['apache2'],
  }

  # TODO the file requires @pupsecrets.
  # reenable once figured out
  # file { '/etc/mediawiki/LocalSettings.php':
  #   ensure  => file,
  #   owner   => root,
  #   group   => www-data,
  #   mode    => '0440',
  #   content => template("datorhandbok/LocalSettings.php.erb"),
  #   require => Package['mediawiki'],
  # }

  file { '/var/lib/mediawiki/skins/lyslogo-liten.png':
    ensure  => file,
    owner   => www-data,
    group   => www-data,
    source  => "puppet:///modules/datorhandbok/lyslogo-liten.png",
    require => Package['mediawiki'],
  }

  file { '/var/lib/mediawiki/favicon.ico':
    ensure  => file,
    owner   => root,
    group   => root,
    source  => "puppet:///modules/datorhandbok/favicon.ico",
    require => Package['mediawiki'],
  }

  file { '/var/lib/mediawiki/extensions/AuthPAM.php':
    ensure  => file,
    owner   => www-data,
    group   => www-data,
    source  => "puppet:///modules/datorhandbok/AuthPAM.php",
    require => Package['mediawiki'],
  }

  file { '/etc/pam.d/datorhandbok':
    ensure => file,
    owner  => root,
    group  => root,
    mode   => '0444',
    source => "puppet:///modules/datorhandbok/pam",
  }

  file { '/etc/mediawiki-extensions/extensions-enabled/RSSReader.php':
    ensure  => symlink,
    target  => '/etc/mediawiki-extensions/extensions-available/RSSReader.php',
    require => Package['mediawiki'],
  }

  file { '/usr/lib/squid3/basic_pam_auth':
    ensure  => file,
    mode    => '2755',
    require => Package['squid3'],
  }
}