diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-01-13 23:15:11 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-01-13 23:53:26 +0100 |
commit | dfa81fe29a6be169d6ed2803c4bedcd211b16d72 (patch) | |
tree | 77bd0d72e5fe48e07b5d7be5f7532b776f9c53ba /manifests/machine.pp | |
parent | Rewrote mots of nspawn. (diff) | |
download | nspawn-dfa81fe29a6be169d6ed2803c4bedcd211b16d72.tar.gz nspawn-dfa81fe29a6be169d6ed2803c4bedcd211b16d72.tar.xz |
Nspawn cleanup.
Diffstat (limited to 'manifests/machine.pp')
-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, |