summaryrefslogtreecommitdiff
path: root/modules/nspawn/manifests/machine.pp
blob: 8ba9bf3b477891895ca4e43e6c1925fb6637cdda (plain)
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
define nspawn::machine (
  String $os,
  Hash $os_opts = {} ,
  String $machine = $name,
  Boolean $enable = false,
) {

  require ::nspawn::setup

  file { "/var/lib/machines/${machine}/puppet":
    ensure => directory,
  }

  file { "/etc/systemd/nspawn/${machine}.nspawn":
    content => @("EOF")
    [Exec]
    Hostname=${machine}.adrift.space
    Boot=true
    # /usr/lib/systemd/resolv.conf
    ResolvConf=copy-static

    [Files]
    # TODO This should only be mounted on puppet servers, in case it
    # contains secrets
    BindReadOnly=/usr/local/puppet:/puppet

    [Network]
    Bridge=br0
    | EOF
  }

  create_resources("nspawn::os::${os}", { $machine => $os_opts })

  service { "systemd-nspawn@${machine}.service":
    enable => $enable,
  }

}