zfs.pp 1.9 KB
Newer Older
1
class nest::base::zfs {
2
  nest::lib::package { 'sys-fs/zfs':
3
    ensure => installed,
4
5
6
    use    => 'kernel-builtin'
  }

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  $zfs_mount_override = @(EOF)
    [Service]
    ExecStart=
    ExecStart=/sbin/zfs mount -al
    | EOF

  file {
    default:
      mode  => '0644',
      owner => 'root',
      group => 'root',
    ;

    '/etc/systemd/system/zfs-mount.service.d':
      ensure => directory,
    ;

24
    '/etc/systemd/system/zfs-mount.service.d/10-load-key.conf':
25
      content => $zfs_mount_override,
James T. Lee's avatar
James T. Lee committed
26
      notify  => Nest::Lib::Systemd_reload['zfs'],
27
28
29
    ;
  }

30
31
  nest::lib::systemd_reload { 'zfs': }

32
  unless $facts['is_container'] or $facts['running_live'] {
33
    exec { 'zgenhostid':
James T. Lee's avatar
James T. Lee committed
34
      command => '/sbin/zgenhostid `hostid`',
35
36
37
38
      creates => '/etc/hostid',
      require => Package['sys-fs/zfs'],
      notify  => Class['::nest::base::dracut'],
    }
James T. Lee's avatar
James T. Lee committed
39
40
  }

41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
  # On systems without ZFS root, the zfs module doesn't get loaded by dracut
  file { '/etc/modules-load.d/zfs.conf':
    mode    => '0644',
    owner   => 'root',
    group   => 'root',
    content => "zfs\n",
  }

  # See: https://github.com/zfsonlinux/zfs/blob/master/etc/systemd/system/50-zfs.preset.in
  service { [
    'zfs-import-cache.service',
    'zfs-mount.service',
    'zfs-share.service',
    'zfs-zed.service',
    'zfs.target',
  ]:
    enable  => true,
    require => Package['sys-fs/zfs'],
  }

61
  unless $facts['is_container'] or $facts['running_live'] {
62
63
64
65
66
    exec { 'generate-zpool-cache':
      command => "/sbin/zpool set cachefile= ${trusted['certname']}",
      creates => '/etc/zfs/zpool.cache',
    }

67
68
69
70
    # Manage swap volume properties for experimenting with workarounds listed in
    # https://github.com/openzfs/zfs/issues/7734
    zfs { "${facts['rpool']}/swap":
      compression    => 'off',
71
      sync           => 'standard',
72
73
74
75
76
      primarycache   => 'metadata',
      secondarycache => 'none',
      logbias        => 'throughput',
    }
  }
77
}