From bdf653fc912638b646c5e04544dd4e735faff924 Mon Sep 17 00:00:00 2001 From: Peter Dedene Date: Thu, 29 Nov 2018 19:02:00 +0100 Subject: [PATCH 1/3] dracut: add hetzner cloud support --- dracut/30ignition/coreos-hcloud-hostname.service | 10 ++++++++++ dracut/30ignition/ignition-generator | 4 ++++ dracut/30ignition/module-setup.sh | 3 +++ 3 files changed, 17 insertions(+) create mode 100644 dracut/30ignition/coreos-hcloud-hostname.service diff --git a/dracut/30ignition/coreos-hcloud-hostname.service b/dracut/30ignition/coreos-hcloud-hostname.service new file mode 100644 index 0000000..b03c352 --- /dev/null +++ b/dracut/30ignition/coreos-hcloud-hostname.service @@ -0,0 +1,10 @@ +[Unit] +Description=CoreOS Hetzner Cloud Hostname Agent +DefaultDependencies=false +Before=initrd.target +After=systemd-networkd.service initrd-root-fs.target +Wants=systemd-networkd.service initrd-root-fs.target + +[Service] +Type=oneshot +ExecStart=/usr/bin/coreos-metadata --cmdline --hostname=/sysroot/etc/hostname diff --git a/dracut/30ignition/ignition-generator b/dracut/30ignition/ignition-generator index 76bb2aa..6de267b 100755 --- a/dracut/30ignition/ignition-generator +++ b/dracut/30ignition/ignition-generator @@ -97,6 +97,10 @@ if [[ $(cmdline_arg coreos.oem.id) == "digitalocean" ]]; then add_requires coreos-digitalocean-network.service fi +if [[ $(cmdline_arg coreos.oem.id) == "hcloud" ]]; then + add_requires coreos-hcloud-hostname.service +fi + oem_id=pxe if [[ $(systemd-detect-virt || true) =~ ^(kvm|qemu)$ ]]; then oem_id=qemu diff --git a/dracut/30ignition/module-setup.sh b/dracut/30ignition/module-setup.sh index 447686a..f396965 100755 --- a/dracut/30ignition/module-setup.sh +++ b/dracut/30ignition/module-setup.sh @@ -49,6 +49,9 @@ install() { inst_simple "$moddir/coreos-digitalocean-network.service" \ "$systemdsystemunitdir/coreos-digitalocean-network.service" + inst_simple "$moddir/coreos-hcloud-hostname.service" \ + "$systemdsystemunitdir/coreos-hcloud-hostname.service" + inst_simple "$moddir/coreos-static-network.service" \ "$systemdsystemunitdir/coreos-static-network.service" From 91487085996913e11a82e16bafa0a732fc4c562f Mon Sep 17 00:00:00 2001 From: Peter Dedene Date: Sun, 2 Dec 2018 18:24:05 +0100 Subject: [PATCH 2/3] dracut: rename to generic static hostname service --- ...oud-hostname.service => coreos-static-hostname.service} | 3 +++ dracut/30ignition/ignition-generator | 7 +++---- dracut/30ignition/module-setup.sh | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) rename dracut/30ignition/{coreos-hcloud-hostname.service => coreos-static-hostname.service} (80%) diff --git a/dracut/30ignition/coreos-hcloud-hostname.service b/dracut/30ignition/coreos-static-hostname.service similarity index 80% rename from dracut/30ignition/coreos-hcloud-hostname.service rename to dracut/30ignition/coreos-static-hostname.service index b03c352..7c3bb1a 100644 --- a/dracut/30ignition/coreos-hcloud-hostname.service +++ b/dracut/30ignition/coreos-static-hostname.service @@ -5,6 +5,9 @@ Before=initrd.target After=systemd-networkd.service initrd-root-fs.target Wants=systemd-networkd.service initrd-root-fs.target +# Ensure Ignition can overwrite /etc/hostname +Before=ignition-files.service + [Service] Type=oneshot ExecStart=/usr/bin/coreos-metadata --cmdline --hostname=/sysroot/etc/hostname diff --git a/dracut/30ignition/ignition-generator b/dracut/30ignition/ignition-generator index 6de267b..573e511 100755 --- a/dracut/30ignition/ignition-generator +++ b/dracut/30ignition/ignition-generator @@ -45,6 +45,9 @@ if $(cmdline_bool coreos.first_boot 0); then if [[ $(cmdline_arg coreos.oem.id) == "packet" ]]; then add_requires coreos-static-network.service fi + if [[ $(cmdline_arg coreos.oem.id) == "hcloud" ]]; then + add_requires coreos-static-hostname.service + fi # On EC2, shut down systemd-networkd if ignition fails so that the instance # fails EC2 instance checks. @@ -97,10 +100,6 @@ if [[ $(cmdline_arg coreos.oem.id) == "digitalocean" ]]; then add_requires coreos-digitalocean-network.service fi -if [[ $(cmdline_arg coreos.oem.id) == "hcloud" ]]; then - add_requires coreos-hcloud-hostname.service -fi - oem_id=pxe if [[ $(systemd-detect-virt || true) =~ ^(kvm|qemu)$ ]]; then oem_id=qemu diff --git a/dracut/30ignition/module-setup.sh b/dracut/30ignition/module-setup.sh index f396965..656bcc6 100755 --- a/dracut/30ignition/module-setup.sh +++ b/dracut/30ignition/module-setup.sh @@ -49,8 +49,8 @@ install() { inst_simple "$moddir/coreos-digitalocean-network.service" \ "$systemdsystemunitdir/coreos-digitalocean-network.service" - inst_simple "$moddir/coreos-hcloud-hostname.service" \ - "$systemdsystemunitdir/coreos-hcloud-hostname.service" + inst_simple "$moddir/coreos-static-hostname.service" \ + "$systemdsystemunitdir/coreos-static-hostname.service" inst_simple "$moddir/coreos-static-network.service" \ "$systemdsystemunitdir/coreos-static-network.service" From 5515ce353694fa4d7bd8a8ec2fc12c92bb041455 Mon Sep 17 00:00:00 2001 From: Peter Dedene Date: Wed, 12 Dec 2018 18:40:02 +0100 Subject: [PATCH 3/3] Change description for static hostname service --- dracut/30ignition/coreos-static-hostname.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dracut/30ignition/coreos-static-hostname.service b/dracut/30ignition/coreos-static-hostname.service index 7c3bb1a..aa9359c 100644 --- a/dracut/30ignition/coreos-static-hostname.service +++ b/dracut/30ignition/coreos-static-hostname.service @@ -1,5 +1,5 @@ [Unit] -Description=CoreOS Hetzner Cloud Hostname Agent +Description=CoreOS Static Hostname Agent DefaultDependencies=false Before=initrd.target After=systemd-networkd.service initrd-root-fs.target