summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-01-01 23:07:49 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2022-01-01 23:20:10 +0100
commit337716a7f106d35cca86ad0ac69a080356dbc32f (patch)
treeb4ec65ddcf3ceaac2f93a81743f65aa3b788564a
parentSetup nspawn? (diff)
downloadnspawn-337716a7f106d35cca86ad0ac69a080356dbc32f.tar.gz
nspawn-337716a7f106d35cca86ad0ac69a080356dbc32f.tar.xz
Hopefully fix nspawn.
-rw-r--r--manifests/machine.pp15
-rw-r--r--manifests/os/arch.pp43
-rw-r--r--manifests/os/debian.pp6
-rw-r--r--manifests/setup.pp2
4 files changed, 16 insertions, 50 deletions
diff --git a/manifests/machine.pp b/manifests/machine.pp
index b308b74..d747069 100644
--- a/manifests/machine.pp
+++ b/manifests/machine.pp
@@ -1,6 +1,6 @@
define nspawn::machine (
String $os,
- String $os_version,
+ Hash $os_opts = {} ,
String $machine = $name,
Boolean $enable = false,
) {
@@ -20,18 +20,7 @@ define nspawn::machine (
| EOF
}
- case $os {
- 'debian': {
- nspawn::os::debian { $machine:
- os_version => $os_version,
- }
- }
- 'arch': {
- nspawn::os::arch { $machine:
- }
- }
- # TODO default fail
- }
+ create_resources("nspawn::os::${os}", { $machine => $os_opts })
service { "systemd-nspawn@${machine}.service":
enable => true,
diff --git a/manifests/os/arch.pp b/manifests/os/arch.pp
index 4f83546..5fbf5d1 100644
--- a/manifests/os/arch.pp
+++ b/manifests/os/arch.pp
@@ -8,7 +8,7 @@ define nspawn::os::arch (
creates => "/var/lib/machines/${machine}/etc/os-release",
}
- file { "/var/lib/machines/${machine}/etc/systemd/network.d/20-puppet.conf":
+ file { "/var/lib/machines/${machine}/etc/systemd/network/20-puppet.conf":
content => @(EOF)
[Match]
Name=host0
@@ -20,39 +20,14 @@ define nspawn::os::arch (
| EOF
}
- $symlinks = [
- [ '/etc/systemd/system/dbus-org.freedesktop.network1.service',
- '/usr/lib/systemd/system/systemd-networkd.service' ],
- [ '/etc/systemd/system/multi-user.target.wants/systemd-networkd.service',
- '/usr/lib/systemd/system/systemd-networkd.service' ],
- [ '/etc/systemd/system/sockets.target.wants/systemd-networkd.socket',
- '/usr/lib/systemd/system/systemd-networkd.socket' ],
- [ '/etc/systemd/system/sysinit.target.wants/systemd-network-generator.service',
- '/usr/lib/systemd/system/systemd-network-generator.service' ],
- [ '/etc/systemd/system/network-online.target.wants/systemd-networkd-wait-online.service',
- '/usr/lib/systemd/system/systemd-networkd-wait-online.service' ],
- ]
-
- $symlinks.each |$pair| {
- $where = $pair[0]
- $target = $pair[1]
- file { "/var/lib/machines/${machine}/${where}":
- ensure => link,
- target => $target,
- }
- }
-
-
- file { "/var/lib/machines/${machine}/etc/systemd/network.d/20-puppet.conf":
- content => @(EOF)
- [Match]
- Name=host0
-
- [Network]
- Address=10.0.0.43/23
- Gateway=10.0.0.1
- IPv6AcceptRA=1
- | EOF
+ exec { "Enable systemd-networkd on ${machine}":
+ command => [ '/usr/bin/systemd-nspawn',
+ '-M', $machine,
+ '--quiet',
+ 'systemctl', 'enable', 'systemd-networkd',
+ ],
+ # among others
+ creates => "/var/lib/machines/${machine}/etc/systemd/system/multi-user.target.wants/systemd-networkd.service",
}
}
diff --git a/manifests/os/debian.pp b/manifests/os/debian.pp
index c821ba6..13d9ac9 100644
--- a/manifests/os/debian.pp
+++ b/manifests/os/debian.pp
@@ -29,11 +29,11 @@ define nspawn::os::debian (
# allow-hotplug host0
iface host0 inet static
- address 10.0.0.42/23
- gateway 10.0.0.1
+ address 10.0.0.42/23
+ gateway 10.0.0.1
iface host0 inet6 auto
- private 0
+ private 0
| EOF
}
diff --git a/manifests/setup.pp b/manifests/setup.pp
index ffd90ee..9f742fd 100644
--- a/manifests/setup.pp
+++ b/manifests/setup.pp
@@ -1,5 +1,7 @@
class nspawn::setup {
+ # TODO find better file to use for containers
+
file { '/usr/lib/systemd/resolv.conf':
ensure => file,
content => @(EOF)