diff --git a/data/data/bootstrap/baremetal/files/usr/local/bin/startironic.sh b/data/data/bootstrap/baremetal/files/usr/local/bin/startironic.sh.template similarity index 97% rename from data/data/bootstrap/baremetal/files/usr/local/bin/startironic.sh rename to data/data/bootstrap/baremetal/files/usr/local/bin/startironic.sh.template index 820e5da6e..413d4bce2 100755 --- a/data/data/bootstrap/baremetal/files/usr/local/bin/startironic.sh +++ b/data/data/bootstrap/baremetal/files/usr/local/bin/startironic.sh.template @@ -7,8 +7,8 @@ IRONIC_INSPECTOR_IMAGE=${IRONIC_INSPECTOR_IMAGE:-"quay.io/metal3-io/ironic-inspe IPA_DOWNLOADER_IMAGE=${IPA_DOWNLOADER_IMAGE:-"quay.io/metal3-io/ironic-ipa-downloader:master"} COREOS_DOWNLOADER_IMAGE=${COREOS_DOWNLOADER_IMAGE:-"quay.io/openshift-metal3/rhcos-downloader:master"} -# FIXME this should be provided by the installer -RHCOS_IMAGE_URL="https://releases-art-rhcos.svc.ci.openshift.org/art/storage/releases/ootpa/410.8.20190520.0" +# This image is templated in via the installer pkg/asset/ignition/bootstrap/bootstrap.go +RHCOS_IMAGE_URL="{{.DeployImage}}" # First we stop any previously started containers, because ExecStop only runs when the ExecStart process # e.g this script is still running, but we exit if *any* of the containers exits unexpectedly diff --git a/pkg/asset/ignition/bootstrap/bootstrap.go b/pkg/asset/ignition/bootstrap/bootstrap.go index b063039ce..6371fa47d 100644 --- a/pkg/asset/ignition/bootstrap/bootstrap.go +++ b/pkg/asset/ignition/bootstrap/bootstrap.go @@ -26,7 +26,9 @@ import ( "github.com/openshift-metalkube/kni-installer/pkg/asset/machines" "github.com/openshift-metalkube/kni-installer/pkg/asset/manifests" "github.com/openshift-metalkube/kni-installer/pkg/asset/tls" + "github.com/openshift-metalkube/kni-installer/pkg/rhcos" "github.com/openshift-metalkube/kni-installer/pkg/types" + bmtypes "github.com/openshift-metalkube/kni-installer/pkg/types/baremetal" ) const ( @@ -42,6 +44,7 @@ type bootstrapTemplateData struct { PullSecret string ReleaseImage string Proxy *configv1.ProxyStatus + DeployImage string } // Bootstrap is an asset that generates the ignition config for bootstrap nodes. @@ -117,6 +120,7 @@ func (a *Bootstrap) Generate(dependencies asset.Parents) error { if err != nil { return errors.Wrap(err, "failed to get bootstrap templates") } + logrus.Debugf("SHDEBUG templateData type %T", templateData) a.Config = &igntypes.Config{ Ignition: igntypes.Ignition{ @@ -208,11 +212,25 @@ func (a *Bootstrap) getTemplateData(installConfig *types.InstallConfig, proxy *c logrus.Debugf("Using internal constant for release image %s", releaseImage) } + var deployImage string + // baremetal requires some additional templateData to download the RHCOS image + // so we can deploy the masters with the correct image from rhcos.json + if installConfig.Platform.Name() == bmtypes.Name { + var err error + deployImage, err = rhcos.Baremetal() + if err != nil { + return nil, err + } + } else { + deployImage = releaseImage + } + return &bootstrapTemplateData{ PullSecret: installConfig.PullSecret, ReleaseImage: releaseImage, EtcdCluster: strings.Join(etcdEndpoints, ","), Proxy: &proxy.Status, + DeployImage: deployImage, }, nil } diff --git a/pkg/rhcos/baremetal.go b/pkg/rhcos/baremetal.go new file mode 100644 index 000000000..d77a42687 --- /dev/null +++ b/pkg/rhcos/baremetal.go @@ -0,0 +1,23 @@ +package rhcos + +import ( + "context" + "net/url" + + "github.com/pkg/errors" +) + +// Baremetal fetches the BaseURI where baremetal images can be downloaded from +func Baremetal() (string, error) { + meta, err := fetchRHCOSBuild(context.TODO()) + if err != nil { + return "", errors.Wrap(err, "failed to fetch RHCOS metadata") + } + + base, err := url.Parse(meta.BaseURI) + if err != nil { + return "", err + } + + return base.String(), nil +}