summaryrefslogtreecommitdiff
path: root/modules/nspawn
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-01-12 02:26:25 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2022-01-12 02:26:25 +0100
commitdd28dcf3d620a4ac7d0a1532b812213cf094cd3c (patch)
treea3fa8c8ef446de2bcc2f317bceb4bca868f7e0f0 /modules/nspawn
parentMove webdav into profiles. (diff)
downloadwebdav_server-dd28dcf3d620a4ac7d0a1532b812213cf094cd3c.tar.gz
webdav_server-dd28dcf3d620a4ac7d0a1532b812213cf094cd3c.tar.xz
Revert "Move webdav into profiles."
It actually reverts the non-need for the nginx module webdav_ext. Since Omnifocus requires PROPFIND. This reverts commit edf6ffe8b399679ba28cc5e558a6838919dd1ee8.
Diffstat (limited to 'modules/nspawn')
-rwxr-xr-xmodules/nspawn/facts.d/main.py64
-rw-r--r--modules/nspawn/manifests/machine.pp38
-rw-r--r--modules/nspawn/manifests/os/arch.pp14
-rw-r--r--modules/nspawn/manifests/os/debian.pp49
-rw-r--r--modules/nspawn/manifests/setup.pp16
-rw-r--r--modules/nspawn/manifests/util/disable_networking.pp22
-rw-r--r--modules/nspawn/manifests/util/enable_networkd.pp38
7 files changed, 0 insertions, 241 deletions
diff --git a/modules/nspawn/facts.d/main.py b/modules/nspawn/facts.d/main.py
deleted file mode 100755
index 0db37f3..0000000
--- a/modules/nspawn/facts.d/main.py
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/usr/bin/env python3
-
-import dbus
-import yaml
-
-bus = dbus.SystemBus()
-bus_name = 'org.freedesktop.machine1' # dest
-object_path = '/org/freedesktop/machine1'
-machined_proxy = bus.get_object(bus_name=bus_name, object_path=object_path)
-iface = dbus.Interface(machined_proxy, dbus_interface='org.freedesktop.machine1.Manager')
-
-
-machines = iface.ListMachines()
-machine_names = []
-machines_info = {}
-for (machine_name, *_) in machines:
- machine = iface.GetMachine(machine_name)
- pp = bus.get_object(bus_name='org.freedesktop.machine1', object_path=machine)
- ii = dbus.Interface(pp, dbus_interface='org.freedesktop.DBus.Properties')
- out_dict = {}
- for key, value in ii.GetAll('org.freedesktop.machine1.Machine').items():
- # see help(dbus.types)
- match type(value):
- case dbus.ByteArray:
- raise NotImplementedError('Byte array')
- case dbus.Double:
- v = float(value)
- case dbus.Boolean:
- v = bool(value)
- case dbus.Byte | dbus.Int16 | dbus.Int32 | dbus.Int64 | dbus.UInt16 | dbus.UInt32 | dbus.UInt64:
- v = int(value)
- case dbus.ObjectPath | dbus.Signature:
- # string likes
- v = str(value)
- case dbus.Dictionary:
- # dict like
- raise NotImplementedError('Dictionary')
- case dbus.Array:
- match value.signature:
- case dbus.Signature('y'):
- v = bytes(int(x) for x in value)
- case dbus.Signature('i'):
- v = [int(x) for x in value]
- case _:
- print(repr(value))
- print(repr(value.signature))
- raise NotImplementedError('Array')
- # case dbus.UnixFd:
- # raise NotImplementedError()
- case dbus.String:
- v = str(value)
- case dbus.Struct:
- # tuple like
- raise NotImplementedError('Struct')
- out_dict[str(key)] = v
- machine_names.append(str(machine_name))
- machines_info[str(machine_name)] = out_dict
-
-out = {
- 'machined-machines': machine_names,
- 'machined-info': machines_info,
-}
-
-print(yaml.dump(out))
diff --git a/modules/nspawn/manifests/machine.pp b/modules/nspawn/manifests/machine.pp
deleted file mode 100644
index 8ba9bf3..0000000
--- a/modules/nspawn/manifests/machine.pp
+++ /dev/null
@@ -1,38 +0,0 @@
-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,
- }
-
-}
diff --git a/modules/nspawn/manifests/os/arch.pp b/modules/nspawn/manifests/os/arch.pp
deleted file mode 100644
index e5fc210..0000000
--- a/modules/nspawn/manifests/os/arch.pp
+++ /dev/null
@@ -1,14 +0,0 @@
-define nspawn::os::arch (
- String $machine = $name,
-) {
-
- ensure_packages(['arch-install-scripts'])
-
- $machine_path = "/var/lib/machines/${machine}"
-
- exec { "/usr/bin/pacstrap '${machine_path}' base puppet":
- creates => "${machine_path}/etc/os-release",
- }
-
- nspawn::util::enable_networkd { $machine: }
-}
diff --git a/modules/nspawn/manifests/os/debian.pp b/modules/nspawn/manifests/os/debian.pp
deleted file mode 100644
index fbab9ac..0000000
--- a/modules/nspawn/manifests/os/debian.pp
+++ /dev/null
@@ -1,49 +0,0 @@
-define nspawn::os::debian (
- String $os_version,
- String $machine = $name,
-) {
-
- ensure_packages(['debootstrap'])
-
- exec { "/usr/bin/deboostrap ${os_version} /var/lib/machines/${machine}":
- creates => "/var/lib/machines/${machine}/etc/os-release",
- }
-
- $puppet_deb = "/var/lib/machines/${machine}/tmp/puppet7-release-${os_version}.deb"
- file { $puppet_deb:
- ensure => file,
- source => "https://apt.puppet.com/puppet7-release-${os_version}.deb"
- }
-
- $running = $facts['machined-info'][$machine] != Undef or $facts['machined-info'][$machine]['State'] == 'running'
-
- if $running {
- # TODO
- notify { "Notify skipping ${machine} setup":
- message => "Skipping setup for ${machine}, already running",
- }
- } else {
- exec { "Set up puppet repo for ${machine}":
- subscribe => File[$puppet_deb],
- command => [ '/usr/bin/systemd-nspawn',
- '-M', $machine,
- '--quiet',
- '/bin/sh', '-c',
- "dpkg -i '/tmp/puppet7-release-${os_version}.deb' && apt update"
- ],
- }
-
- exec { "install puppet-agent on ${machine}":
- command => [ '/usr/bin/systemd-nspawn',
- '-M', $machine,
- '--quiet',
- 'apt', 'install', 'puppet-agent',
- ],
- creates => "/var/lib/machines/${machine}/opt/puppetlabs/bin/puppet",
- }
- }
-
- nspawn::util::disable_networking { $machine: }
- nspawn::util::enable_networkd { $machine: }
-
-}
diff --git a/modules/nspawn/manifests/setup.pp b/modules/nspawn/manifests/setup.pp
deleted file mode 100644
index 9f742fd..0000000
--- a/modules/nspawn/manifests/setup.pp
+++ /dev/null
@@ -1,16 +0,0 @@
-class nspawn::setup {
-
- # TODO find better file to use for containers
-
- file { '/usr/lib/systemd/resolv.conf':
- ensure => file,
- content => @(EOF)
- # File /usr/lib/systemd/resolv.conf managed by puppet
- # Local changes will be overwritten
- nameserver 10.0.0.40
- search adrift.space
- | EOF
- }
-
-
-}
diff --git a/modules/nspawn/manifests/util/disable_networking.pp b/modules/nspawn/manifests/util/disable_networking.pp
deleted file mode 100644
index 4a9b31b..0000000
--- a/modules/nspawn/manifests/util/disable_networking.pp
+++ /dev/null
@@ -1,22 +0,0 @@
-define nspawn::util::disable_networking (
- String $machine = $name,
- String $machine_path = "/var/lib/machines/${machine}",
-) {
-
-
- $cmd = if $facts['machined-info'][$machine]['State'] == 'running' {
- [ 'systemctl', '-M', $machine, 'disable', 'networking' ]
- } else {
- [ 'systemd-nspawn', '-M', $machine, '--quiet',
- 'systemctl', 'disable', 'networking' ]
- }
-
- exec { "Disable networking on ${machine}":
- command => $cmd,
- path => [ '/bin', '/usr/bin', ],
- # among others
- # creates => "${machine_path}/etc/systemd/system/multi-user.target.wants/systemd-networkd.service",
- }
-
-}
-
diff --git a/modules/nspawn/manifests/util/enable_networkd.pp b/modules/nspawn/manifests/util/enable_networkd.pp
deleted file mode 100644
index 8e447b9..0000000
--- a/modules/nspawn/manifests/util/enable_networkd.pp
+++ /dev/null
@@ -1,38 +0,0 @@
-define nspawn::util::enable_networkd (
- String $machine = $name,
- String $machine_path = "/var/lib/machines/${machine}",
-) {
-
- # TODO only do this if the directory is empty
- networking::networkd_instance { "Initial networking on ${machine}":
- priority => 50,
- filename => 'puppet-initial',
- path => "${machine_path}/${networking::networkd::path}",
- content => {
- 'Match' => {
- 'Name' => 'host0',
- },
- 'Network' => {
- 'DHCP' => 'ipv4',
- 'IPv6AcceptRA' => 1,
- },
- },
- }
-
- $running = $facts['machined-info'][$machine] != Undef or $facts['machined-info'][$machine]['State'] == 'running'
-
- $cmd = if $running {
- [ 'systemctl', '-M', $machine, 'enable', 'systemd-networkd' ]
- } else {
- [ 'systemd-nspawn', '-M', $machine, '--quiet',
- 'systemctl', 'enable', 'systemd-networkd' ]
- }
-
- exec { "Enable systemd-networkd on ${machine}":
- command => $cmd,
- path => [ '/bin', '/usr/bin', ],
- # among others
- creates => "${machine_path}/etc/systemd/system/multi-user.target.wants/systemd-networkd.service",
- }
-
-}