From 6aba1395327aa5fa8a7ab38265268bcb4385fc81 Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Tue, 11 Jun 2019 18:59:33 +0100 Subject: [PATCH] Enable platform dependent bootstrap ignition files Some of the additions made should only be enabled for the baremetal platform, so move these to data/data/bootstrap/baremetal and adjust the code to conditionally read this depending on the platform name. Closes: #62 Related: #64 --- .../files/etc/coredns/Corefile | 0 .../files/etc/dhcp/dhclient.conf | 0 .../files/etc/keepalived/keepalived.conf.tmpl | 0 .../files/usr/local/bin/coredns.sh | 0 .../files/usr/local/bin/keepalived.sh | 0 .../systemd/units/coredns.service | 0 .../systemd/units/keepalived.service | 0 pkg/asset/ignition/bootstrap/bootstrap.go | 27 +++++++++++++++++-- 8 files changed, 25 insertions(+), 2 deletions(-) rename data/data/bootstrap/{ => baremetal}/files/etc/coredns/Corefile (100%) rename data/data/bootstrap/{ => baremetal}/files/etc/dhcp/dhclient.conf (100%) rename data/data/bootstrap/{ => baremetal}/files/etc/keepalived/keepalived.conf.tmpl (100%) rename data/data/bootstrap/{ => baremetal}/files/usr/local/bin/coredns.sh (100%) rename data/data/bootstrap/{ => baremetal}/files/usr/local/bin/keepalived.sh (100%) rename data/data/bootstrap/{ => baremetal}/systemd/units/coredns.service (100%) rename data/data/bootstrap/{ => baremetal}/systemd/units/keepalived.service (100%) diff --git a/data/data/bootstrap/files/etc/coredns/Corefile b/data/data/bootstrap/baremetal/files/etc/coredns/Corefile similarity index 100% rename from data/data/bootstrap/files/etc/coredns/Corefile rename to data/data/bootstrap/baremetal/files/etc/coredns/Corefile diff --git a/data/data/bootstrap/files/etc/dhcp/dhclient.conf b/data/data/bootstrap/baremetal/files/etc/dhcp/dhclient.conf similarity index 100% rename from data/data/bootstrap/files/etc/dhcp/dhclient.conf rename to data/data/bootstrap/baremetal/files/etc/dhcp/dhclient.conf diff --git a/data/data/bootstrap/files/etc/keepalived/keepalived.conf.tmpl b/data/data/bootstrap/baremetal/files/etc/keepalived/keepalived.conf.tmpl similarity index 100% rename from data/data/bootstrap/files/etc/keepalived/keepalived.conf.tmpl rename to data/data/bootstrap/baremetal/files/etc/keepalived/keepalived.conf.tmpl diff --git a/data/data/bootstrap/files/usr/local/bin/coredns.sh b/data/data/bootstrap/baremetal/files/usr/local/bin/coredns.sh similarity index 100% rename from data/data/bootstrap/files/usr/local/bin/coredns.sh rename to data/data/bootstrap/baremetal/files/usr/local/bin/coredns.sh diff --git a/data/data/bootstrap/files/usr/local/bin/keepalived.sh b/data/data/bootstrap/baremetal/files/usr/local/bin/keepalived.sh similarity index 100% rename from data/data/bootstrap/files/usr/local/bin/keepalived.sh rename to data/data/bootstrap/baremetal/files/usr/local/bin/keepalived.sh diff --git a/data/data/bootstrap/systemd/units/coredns.service b/data/data/bootstrap/baremetal/systemd/units/coredns.service similarity index 100% rename from data/data/bootstrap/systemd/units/coredns.service rename to data/data/bootstrap/baremetal/systemd/units/coredns.service diff --git a/data/data/bootstrap/systemd/units/keepalived.service b/data/data/bootstrap/baremetal/systemd/units/keepalived.service similarity index 100% rename from data/data/bootstrap/systemd/units/keepalived.service rename to data/data/bootstrap/baremetal/systemd/units/keepalived.service diff --git a/pkg/asset/ignition/bootstrap/bootstrap.go b/pkg/asset/ignition/bootstrap/bootstrap.go index 8a42fcfe9..2385760a5 100644 --- a/pkg/asset/ignition/bootstrap/bootstrap.go +++ b/pkg/asset/ignition/bootstrap/bootstrap.go @@ -127,6 +127,28 @@ func (a *Bootstrap) Generate(dependencies asset.Parents) error { if err != nil { return err } + + // Check for optional platform specific files/units + platform := installConfig.Config.Platform.Name() + platformFilePath := fmt.Sprintf("bootstrap/%s/files", platform) + directory, err := data.Assets.Open(platformFilePath) + if directory != nil { + directory.Close() + err = a.addStorageFiles("/", platformFilePath, templateData) + if err != nil { + return err + } + } + platformUnitPath := fmt.Sprintf("bootstrap/%s/systemd/units", platform) + directory, err = data.Assets.Open(platformUnitPath) + if directory != nil { + directory.Close() + err = a.addSystemdUnits(platformUnitPath, templateData) + if err != nil { + return err + } + } + a.addParentFiles(dependencies) a.Config.Passwd.Users = append( @@ -247,10 +269,11 @@ func (a *Bootstrap) addSystemdUnits(uri string, templateData *bootstrapTemplateD "progress.service": {}, "kubelet.service": {}, "chown-gatewayd-key.service": {}, - "keepalived.service": {}, - "coredns.service": {}, "systemd-journal-gatewayd.socket": {}, "approve-csr.service": {}, + // baremetal platform services + "keepalived.service": {}, + "coredns.service": {}, } directory, err := data.Assets.Open(uri)