Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ require (
github.com/metal3-io/baremetal-operator v0.0.0
github.com/metal3-io/cluster-api-provider-baremetal v0.0.0
github.com/mitchellh/cli v1.0.0
github.com/opencontainers/image-spec v1.0.2-0.20190823105129-775207bd45b6 // indirect
github.com/openshift-metal3/terraform-provider-ironic v0.2.1
github.com/openshift/api v3.9.1-0.20191111211345-a27ff30ebf09+incompatible
github.com/openshift/client-go v0.0.0-20200320150128-a906f3d8e723
Expand Down Expand Up @@ -114,7 +113,7 @@ replace (
github.com/metal3-io/cluster-api-provider-baremetal => github.com/openshift/cluster-api-provider-baremetal v0.0.0-20190821174549-a2a477909c1d // Pin OpenShift fork
github.com/openshift/api => github.com/openshift/api v0.0.0-20200601094953-95abe2d2f422 // Pin API
github.com/openshift/client-go => github.com/openshift/client-go v0.0.0-20200116152001-92a2713fa240 // Pin client-go
github.com/openshift/machine-config-operator => github.com/openshift/machine-config-operator v0.0.1-0.20200130220348-e5685c0cf530 // Pin MCO so it doesn't get downgraded
github.com/openshift/machine-config-operator => github.com/openshift/machine-config-operator v0.0.1-0.20200609021741-16da55b2a211 // Pin MCO so it doesn't get downgraded
github.com/terraform-providers/terraform-provider-aws => github.com/openshift/terraform-provider-aws v1.60.1-0.20200526184553-1a716dcc0fa8 // Pin to openshift fork with tag v2.60.0-openshift-1
github.com/terraform-providers/terraform-provider-azurerm => github.com/openshift/terraform-provider-azurerm v1.40.1-0.20200508151851-2bfa0b7d4a9d // release-2.8.0 branch
github.com/terraform-providers/terraform-provider-vsphere => github.com/openshift/terraform-provider-vsphere v1.18.1-openshift-1
Expand Down
154 changes: 29 additions & 125 deletions go.sum

Large diffs are not rendered by default.

28 changes: 1 addition & 27 deletions pkg/asset/cluster/tfvars.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ package cluster

import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"strings"

igntypes "github.com/coreos/ignition/config/v2_2/types"
gcpprovider "github.com/openshift/cluster-api-provider-gcp/pkg/apis/gcpprovider/v1beta1"
libvirtprovider "github.com/openshift/cluster-api-provider-libvirt/pkg/apis/libvirtproviderconfig/v1beta1"
ovirtprovider "github.com/openshift/cluster-api-provider-ovirt/pkg/apis/ovirtprovider/v1beta1"
Expand All @@ -29,7 +27,6 @@ import (
openstackconfig "github.com/openshift/installer/pkg/asset/installconfig/openstack"
ovirtconfig "github.com/openshift/installer/pkg/asset/installconfig/ovirt"
"github.com/openshift/installer/pkg/asset/machines"
"github.com/openshift/installer/pkg/asset/openshiftinstall"
"github.com/openshift/installer/pkg/asset/rhcos"
"github.com/openshift/installer/pkg/tfvars"
awstfvars "github.com/openshift/installer/pkg/tfvars/aws"
Expand Down Expand Up @@ -112,7 +109,7 @@ func (t *TerraformVariables) Generate(parents asset.Parents) error {
}

masterIgn := string(masterIgnAsset.Files()[0].Data)
bootstrapIgn, err := injectInstallInfo(bootstrapIgnAsset.Files()[0].Data)
bootstrapIgn, err := ignition.InjectInstallInfo(bootstrapIgnAsset.Files()[0].Data)
if err != nil {
return errors.Wrap(err, "unable to inject installation info")
}
Expand Down Expand Up @@ -539,26 +536,3 @@ func (t *TerraformVariables) Load(f asset.FileFetcher) (found bool, err error) {

return true, nil
}

// injectInstallInfo adds information about the installer and its invoker as a
// ConfigMap to the provided bootstrap Ignition config.
func injectInstallInfo(bootstrap []byte) (string, error) {
config := &igntypes.Config{}
if err := json.Unmarshal(bootstrap, &config); err != nil {
return "", errors.Wrap(err, "failed to unmarshal bootstrap Ignition config")
}

cm, err := openshiftinstall.CreateInstallConfigMap("openshift-install")
if err != nil {
return "", errors.Wrap(err, "failed to generate openshift-install config")
}

config.Storage.Files = append(config.Storage.Files, ignition.FileFromString("/opt/openshift/manifests/openshift-install.yaml", "root", 0644, cm))

ign, err := json.Marshal(config)
if err != nil {
return "", errors.Wrap(err, "failed to marshal bootstrap Ignition config")
}

return string(ign), nil
}
63 changes: 14 additions & 49 deletions pkg/asset/ignition/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import (
"text/template"

"github.com/containers/image/pkg/sysregistriesv2"
"github.com/coreos/ignition/config/util"
igntypes "github.com/coreos/ignition/config/v2_2/types"
configv1 "github.com/openshift/api/config/v1"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -66,7 +64,7 @@ type platformTemplateData struct {

// Bootstrap is an asset that generates the ignition config for bootstrap nodes.
type Bootstrap struct {
Config *igntypes.Config
Config *ignition.Config
File *asset.File
}

Expand Down Expand Up @@ -145,11 +143,7 @@ func (a *Bootstrap) Generate(dependencies asset.Parents) error {
return errors.Wrap(err, "failed to get bootstrap templates")
}

a.Config = &igntypes.Config{
Ignition: igntypes.Ignition{
Version: igntypes.MaxVersion.String(),
},
}
a.Config = ignition.GenerateMinimalConfig()

err = a.addStorageFiles("/", "bootstrap/files", templateData)
if err != nil {
Expand Down Expand Up @@ -184,13 +178,7 @@ func (a *Bootstrap) Generate(dependencies asset.Parents) error {

a.addParentFiles(dependencies)

a.Config.Passwd.Users = append(
a.Config.Passwd.Users,
igntypes.PasswdUser{Name: "core", SSHAuthorizedKeys: []igntypes.SSHAuthorizedKey{
igntypes.SSHAuthorizedKey(installConfig.Config.SSHKey),
igntypes.SSHAuthorizedKey(string(bootstrapSSHKeyPair.Public())),
}},
)
a.Config.AddSSHKey(installConfig.Config.SSHKey, string(bootstrapSSHKeyPair.Public()))

data, err := json.Marshal(a.Config)
if err != nil {
Expand Down Expand Up @@ -318,7 +306,7 @@ func (a *Bootstrap) addStorageFiles(base string, uri string, templateData *boots
ign.Append = appendToFile

// Replace files that already exist in the slice with ones added later, otherwise append them
a.Config.Storage.Files = replaceOrAppend(a.Config.Storage.Files, ign)
a.Config.ReplaceOrAppend(ign)

return nil
}
Expand Down Expand Up @@ -375,7 +363,7 @@ func (a *Bootstrap) addSystemdUnits(uri string, templateData *bootstrapTemplateD
return err
}

dropins := []igntypes.SystemdDropin{}
dropins := []ignition.Dropin{}
for _, childInfo := range children {
file, err := data.Assets.Open(path.Join(dir, childInfo.Name()))
if err != nil {
Expand All @@ -388,35 +376,23 @@ func (a *Bootstrap) addSystemdUnits(uri string, templateData *bootstrapTemplateD
return err
}

dropins = append(dropins, igntypes.SystemdDropin{
dropins = append(dropins, ignition.Dropin{
Name: childName,
Contents: string(contents),
})
}

name := strings.TrimSuffix(childInfo.Name(), ".d")
unit := igntypes.Unit{
Name: name,
Dropins: dropins,
}
if _, ok := enabled[name]; ok {
unit.Enabled = util.BoolToPtr(true)
}
a.Config.Systemd.Units = append(a.Config.Systemd.Units, unit)
_, unitEnabled := enabled[name]
a.Config.AddSystemdDropins(name, dropins, unitEnabled)
} else {
name, contents, err := readFile(childInfo.Name(), file, templateData)
if err != nil {
return err
}

unit := igntypes.Unit{
Name: name,
Contents: string(contents),
}
if _, ok := enabled[name]; ok {
unit.Enabled = util.BoolToPtr(true)
}
a.Config.Systemd.Units = append(a.Config.Systemd.Units, unit)
_, unitEnabled := enabled[name]
a.Config.AddSystemdUnit(name, string(contents), unitEnabled)
}
}

Expand Down Expand Up @@ -459,7 +435,7 @@ func (a *Bootstrap) addParentFiles(dependencies asset.Parents) {

// Replace files that already exist in the slice with ones added later, otherwise append them
for _, file := range ignition.FilesFromAsset(rootDir, "root", 0644, asset) {
a.Config.Storage.Files = replaceOrAppend(a.Config.Storage.Files, file)
a.Config.ReplaceOrAppend(file)
}
}

Expand Down Expand Up @@ -512,24 +488,13 @@ func (a *Bootstrap) addParentFiles(dependencies asset.Parents) {

// Replace files that already exist in the slice with ones added later, otherwise append them
for _, file := range ignition.FilesFromAsset(rootDir, "root", 0600, asset) {
a.Config.Storage.Files = replaceOrAppend(a.Config.Storage.Files, file)
a.Config.ReplaceOrAppend(file)
}
}

rootCA := &tls.RootCA{}
dependencies.Get(rootCA)
a.Config.Storage.Files = replaceOrAppend(a.Config.Storage.Files, ignition.FileFromBytes(filepath.Join(rootDir, rootCA.CertFile().Filename), "root", 0644, rootCA.Cert()))
}

func replaceOrAppend(files []igntypes.File, file igntypes.File) []igntypes.File {
for i, f := range files {
if f.Node.Path == file.Node.Path {
files[i] = file
return files
}
}
files = append(files, file)
return files
a.Config.ReplaceOrAppend(ignition.FileFromBytes(filepath.Join(rootDir, rootCA.CertFile().Filename), "root", 0644, rootCA.Cert()))
}

func applyTemplateData(template *template.Template, templateData interface{}) string {
Expand All @@ -550,7 +515,7 @@ func (a *Bootstrap) Load(f asset.FileFetcher) (found bool, err error) {
return false, err
}

config := &igntypes.Config{}
config := &ignition.Config{}
if err := json.Unmarshal(file.Data, config); err != nil {
return false, errors.Wrapf(err, "failed to unmarshal %s", bootstrapIgnFilename)
}
Expand Down
Loading