summaryrefslogtreecommitdiff
path: root/manifests/machine.pp
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2023-06-21 21:45:18 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2023-06-21 21:45:18 +0200
commit1b7a898c7a336778c0e43ce6e26a36e43cf1080b (patch)
tree4b825dc642cb6eb9a060e54bf8d69288fbee4904 /manifests/machine.pp
parentReordering. (diff)
downloadnspawn-1b7a898c7a336778c0e43ce6e26a36e43cf1080b.tar.gz
nspawn-1b7a898c7a336778c0e43ce6e26a36e43cf1080b.tar.xz
Remove everything.
Remove everything in the module, to make room for a new module in its place (but keeping the history, just in case). The problem with this module was that it tried way to hard to handle the machines by itself, while that should be done outside puppet. The new module will have a much simpler idea of how to provission, not attempt to build machines from scratch, and especially not do anything expensive.
Diffstat (limited to 'manifests/machine.pp')
-rw-r--r--manifests/machine.pp72
1 files changed, 0 insertions, 72 deletions
diff --git a/manifests/machine.pp b/manifests/machine.pp
deleted file mode 100644
index e6d01e2..0000000
--- a/manifests/machine.pp
+++ /dev/null
@@ -1,72 +0,0 @@
-define nspawn::machine (
- String $template,
- String $machine = $name,
- Boolean $enable = false,
- String $machine_dir = $nspawn::machine_dir,
- Hash $nspawn_opts = {},
-) {
-
- require ::nspawn::setup
-
- # TODO
- # gather fact from 'machinectl list-images', and check if one with
- # our name + '.base' exists
-
- $domain = $facts['domain']
- $root = "${machine_dir}/${machine}"
-
- exec { "lvcreate -n vm-${machine} -V 100G --thinpool lvpoolData VolGroup":
- creates => "/dev/VolGroup/vm-${machine}",
- path => ['/usr/bin',],
- } -> systemd_mount { "/var/lib/machines/${machine}":
- what => "/dev/VolGroup/vm-${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/${template}.base",
- '--quiet',
- '-D', $machine,
- '/bin/true', # run some command so we don't get stuck on boot prompt
- ],
- path => ['/bin','/usr/bin'],
- cwd => $machine_dir,
- creates => "${machine_dir}/${machine}",
- }
-
- file { "/var/lib/machines/${machine}/etc/hostname":
- ensure => file,
- content => "${machine}.${domain}\n",
- require => Exec["Create ${machine} from template"],
- }
-
- # systemd-nspawn --quiet -M debby systemctl enable puppet
-
- $nspawn_data = {
- 'Exec' => {
- # 'Hostname' => "${machine}.${domain}",
- 'Boot' => 'true',
- 'ResolvConf' => 'copy-static', # /usr/lib/systemd/resolv.conf
- },
- 'Network' => {
- 'Bridge' => 'br0',
- }
- # TODO deep merge?
- } + $nspawn_opts
-
- file { "/etc/systemd/nspawn/${machine}.nspawn":
- ensure => file,
- content => epp('nspawn/unit_file.epp', {
- data => $nspawn_data,
- }),
- notify => Service["systemd-nspawn@${machine}.service"],
- }
-
- service { "systemd-nspawn@${machine}.service":
- enable => $enable,
- require => File["/etc/systemd/nspawn/${machine}.nspawn"],
- }
-
-}