diff options
Diffstat (limited to '')
-rw-r--r-- | manifests/machine.pp | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/manifests/machine.pp b/manifests/machine.pp index 8cc1947..a22855b 100644 --- a/manifests/machine.pp +++ b/manifests/machine.pp @@ -1,30 +1,32 @@ define nspawn::machine ( - String $os, - Hash $os_opts = {} , + String $template, String $machine = $name, Boolean $enable = false, + String $machine_dir = $nspawn::machine_dir, + Hash $nspawn_opts = {}, ) { require ::nspawn::setup - $domain = $facts['domain'] + # TODO + # gather fact from 'machinectl list-images', and check if one with + # our name + '.base' exists - # Sets up image - # create_resources("nspawn::os::${os}", { $machine => $os_opts }) - nspawn::os::debian { 'debian-bullseye.base': - * => $os_opts, - } + $domain = $facts['domain'] + $root = "${machine_dir}/${machine}" # Copies image to us + # TODO does this actually do anything more than a deep copy? exec { "Create ${machine} from template": command => [ 'systemd-nspawn', - '--template=/var/lib/machines/debian-bullseye.base', + "--template=/var/lib/machines/${template}.base", + '--quiet', '-D', $machine, + '/bin/true', # run some command so we don't get stuck on boot prompt ], path => ['/bin','/usr/bin'], - cwd => '/var/lib/machines', - creates => "/var/lib/machines/${machine}", - require => Nspawn::Os::Debian['debian-bullseye.base'], + cwd => $machine_dir, + creates => "${machine_dir}/${machine}", } file { "/var/lib/machines/${machine}/etc/hostname": @@ -44,7 +46,8 @@ define nspawn::machine ( 'Network' => { 'Bridge' => 'br0', } - } + # TODO deep merge? + } + $nspawn_opts file { "/etc/systemd/nspawn/${machine}.nspawn": ensure => file, |