1
0
mirror of https://github.com/openshift/installer.git synced 2026-02-06 00:48:45 +01:00

*: remove support for environment variables

The environment variables were originally added to make CI testing a
little easier, since the installer didn't support consumption of
provided assets (e.g. the install config). Now that the installer
supports consumption, there is no need for most of the environment
variables anymore. The variables have actually been confusing to users,
so their removal should simplify the mental model.
This commit is contained in:
Alex Crawford
2018-12-10 14:18:50 -08:00
parent 717e2a0356
commit 6be4c253e4
12 changed files with 18 additions and 164 deletions

View File

@@ -223,15 +223,6 @@ Set `TAGS` when building if you need `destroy cluster` support for libvirt; this
TAGS=libvirt_destroy hack/build.sh
```
To avoid being prompted repeatedly, you can set [environment variables](../user/environment-variables.md) to reflect your libvirt choices. For example, selecting libvirt, setting [our earlier name choices](#pick-names), and telling both the installer and the machine-API operator to contact `libvirtd` at [the usual libvirt IP](#firewall), you can use:
```sh
export OPENSHIFT_INSTALL_PLATFORM=libvirt
export OPENSHIFT_INSTALL_BASE_DOMAIN=tt.testing
export OPENSHIFT_INSTALL_CLUSTER_NAME=test1
export OPENSHIFT_INSTALL_LIBVIRT_URI=qemu+tcp://192.168.122.1/system
```
## Cleanup
If you compiled with `libvirt_destroy`, you can use:

View File

@@ -1,51 +0,0 @@
# Environment Variables
The installer accepts a number of environment variable that allow the interactive prompts to be bypassed. Setting any of the following environment variables to their corresponding value, will cause the installer to use that value instead of prompting.
## General
* `OPENSHIFT_INSTALL_BASE_DOMAIN`:
The base domain of the cluster.
All DNS records will be sub-domains of this base and will also include the cluster name.
For AWS, this must be a previously-existing public Route 53 zone. You can check for any already in your account with:
```sh
aws route53 list-hosted-zones --query 'HostedZones[? !(Config.PrivateZone)].Name' --output text
```
* `OPENSHIFT_INSTALL_CLUSTER_NAME`:
The name of the cluster.
This will be used when generating sub-domains.
For libvirt, choose a name that is unique enough to be used as a prefix during cluster deletion.
For example, if you use `demo` as your cluster name, `openshift-install destroy cluster` may destroy all domains, networks, pools, and volumes that begin with `demo`.
* `OPENSHIFT_INSTALL_PLATFORM`:
The platform onto which the cluster will be installed.
Valid values are `aws` and `libvirt`.
* `OPENSHIFT_INSTALL_PULL_SECRET`:
The container registry pull secret for this cluster (e.g. `{"auths": {...}}`).
You can get this secret from [try.openshift.com](https://try.openshift.com).
* `OPENSHIFT_INSTALL_PULL_SECRET_PATH`:
As an alternative to `OPENSHIFT_INSTALL_PULL_SECRET`, you can configure this variable with a path containing your pull secret.
* `OPENSHIFT_INSTALL_SSH_PUB_KEY`:
The SSH public key used to access all nodes within the cluster (e.g. `ssh-rsa AAAA...`).
This is optional.
* `OPENSHIFT_INSTALL_SSH_PUB_KEY_PATH`:
As an alternative to `OPENSHIFT_INSTALL_SSH_PUB_KEY`, you can configure this variable with a path containing your SSH public key (e.g. `~/.ssh/id_rsa.pub`).
## Platform-Specific
* `AWS_PROFILE`:
The AWS profile that corresponds to value in `${HOME}/.aws/credentials`. If not provided, the default is "default".
* `OPENSHIFT_INSTALL_AWS_REGION`:
The AWS region to be used for installation.
* `OPENSHIFT_INSTALL_LIBVIRT_URI`:
The libvirt connection URI to be used.
This must be accessible from the running cluster.
* `OPENSHIFT_INSTALL_LIBVIRT_IMAGE`:
The URI for the OS image.
For example it might be a URI like `https://example.com/rhcos-qemu.qcow2` or a local file like `file:///tmp/redhat-coreos-maipo-47.78-qemu.qcow2`.
**Warning**: you should only set this if you're testing RHCOS releases.
Most users should allow the installer to choose the OS image.

View File

@@ -2,7 +2,6 @@
package aws
import (
"encoding/json"
"fmt"
"os"
"path/filepath"
@@ -112,23 +111,14 @@ func Platform() (*aws.Platform, error) {
}),
Transform: regionTransform,
},
"OPENSHIFT_INSTALL_AWS_REGION",
)
if err != nil {
return nil, err
}
userTags := map[string]string{}
if value, ok := os.LookupEnv("_CI_ONLY_STAY_AWAY_OPENSHIFT_INSTALL_AWS_USER_TAGS"); ok {
if err := json.Unmarshal([]byte(value), &userTags); err != nil {
return nil, errors.Wrapf(err, "_CI_ONLY_STAY_AWAY_OPENSHIFT_INSTALL_AWS_USER_TAGS contains invalid JSON: %s", value)
}
}
return &aws.Platform{
VPCCIDRBlock: defaultVPCCIDR,
Region: region,
UserTags: userTags,
}, nil
}
@@ -141,7 +131,6 @@ func getCredentials() error {
Help: "The AWS access key ID to use for installation (this is not your username).\nhttps://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html",
},
},
"",
)
if err != nil {
return err
@@ -155,7 +144,6 @@ func getCredentials() error {
Help: "The AWS secret access key corresponding to your access key ID (this is not your password).",
},
},
"",
)
if err != nil {
return err

View File

@@ -31,7 +31,6 @@ func (a *baseDomain) Generate(asset.Parents) error {
return validate.DomainName(ans.(string))
}),
},
"OPENSHIFT_INSTALL_BASE_DOMAIN",
)
a.BaseDomain = bd
return err

View File

@@ -31,7 +31,6 @@ func (a *clusterName) Generate(asset.Parents) error {
return validate.DomainName(ans.(string))
}),
},
"OPENSHIFT_INSTALL_CLUSTER_NAME",
)
a.ClusterName = n
return err

View File

@@ -31,7 +31,6 @@ func (a *emailAddress) Generate(asset.Parents) error {
return validate.Email(ans.(string))
}),
},
"OPENSHIFT_INSTALL_EMAIL_ADDRESS",
)
a.EmailAddress = email
return err

View File

@@ -5,7 +5,6 @@ import (
"context"
"fmt"
"net/url"
"os"
"github.com/pkg/errors"
survey "gopkg.in/AlecAivazis/survey.v1"
@@ -32,23 +31,14 @@ func Platform() (*libvirt.Platform, error) {
},
Validate: survey.ComposeValidators(survey.Required, uriValidator),
},
"OPENSHIFT_INSTALL_LIBVIRT_URI",
)
if err != nil {
return nil, err
}
qcowImage, ok := os.LookupEnv("OPENSHIFT_INSTALL_LIBVIRT_IMAGE")
if ok {
err = validURI(qcowImage)
if err != nil {
return nil, errors.Wrap(err, "resolve OPENSHIFT_INSTALL_LIBVIRT_IMAGE")
}
} else {
qcowImage, err = rhcos.QEMU(context.TODO(), rhcos.DefaultChannel)
if err != nil {
return nil, errors.Wrap(err, "failed to fetch QEMU image URL")
}
qcowImage, err := rhcos.QEMU(context.TODO(), rhcos.DefaultChannel)
if err != nil {
return nil, errors.Wrap(err, "failed to fetch QEMU image URL")
}
return &libvirt.Platform{

View File

@@ -150,7 +150,6 @@ func Platform() (*openstack.Platform, error) {
return nil
}),
},
"OPENSHIFT_INSTALL_OPENSTACK_CLOUD",
)
if err != nil {
return nil, err
@@ -178,7 +177,6 @@ func Platform() (*openstack.Platform, error) {
return nil
}),
},
"OPENSHIFT_INSTALL_OPENSTACK_REGION",
)
if err != nil {
return nil, err
@@ -206,7 +204,6 @@ func Platform() (*openstack.Platform, error) {
return nil
}),
},
"OPENSHIFT_INSTALL_OPENSTACK_IMAGE",
)
if err != nil {
return nil, err
@@ -233,7 +230,6 @@ func Platform() (*openstack.Platform, error) {
return nil
}),
},
"OPENSHIFT_INSTALL_OPENSTACK_EXTERNAL_NETWORK",
)
if err != nil {
return nil, errors.Wrapf(err, "failed to Marshal %s platform", openstack.Name)

View File

@@ -80,6 +80,5 @@ func (a *platform) queryUserForPlatform() (string, error) {
return nil
}),
},
"OPENSHIFT_INSTALL_PLATFORM",
)
}

View File

@@ -20,7 +20,7 @@ func (a *pullSecret) Dependencies() []asset.Asset {
// Generate queries for the pull secret from the user.
func (a *pullSecret) Generate(asset.Parents) error {
s, err := asset.GenerateUserProvidedAssetForPath(
s, err := asset.GenerateUserProvidedAsset(
a.Name(),
&survey.Question{
Prompt: &survey.Input{
@@ -31,8 +31,6 @@ func (a *pullSecret) Generate(asset.Parents) error {
return validate.JSON([]byte(ans.(string)))
}),
},
"OPENSHIFT_INSTALL_PULL_SECRET",
"OPENSHIFT_INSTALL_PULL_SECRET_PATH",
)
a.PullSecret = s
return err

View File

@@ -47,38 +47,21 @@ func readSSHKey(path string) (string, error) {
// Generate generates the SSH public key asset.
func (a *sshPublicKey) Generate(asset.Parents) error {
if value, ok := os.LookupEnv("OPENSHIFT_INSTALL_SSH_PUB_KEY"); ok {
if value != "" {
if err := validate.SSHPublicKey(value); err != nil {
return errors.Wrap(err, "failed to validate public key")
}
}
a.Key = value
return nil
pubKeys := map[string]string{
none: "",
}
pubKeys := map[string]string{}
if path, ok := os.LookupEnv("OPENSHIFT_INSTALL_SSH_PUB_KEY_PATH"); ok {
key, err := readSSHKey(path)
home := os.Getenv("HOME")
if home != "" {
paths, err := filepath.Glob(filepath.Join(home, ".ssh", "*.pub"))
if err != nil {
return errors.Wrap(err, "failed to read public key file")
return errors.Wrap(err, "failed to glob for public key files")
}
pubKeys[path] = key
} else {
pubKeys[none] = ""
home := os.Getenv("HOME")
if home != "" {
paths, err := filepath.Glob(filepath.Join(home, ".ssh", "*.pub"))
for _, path := range paths {
key, err := readSSHKey(path)
if err != nil {
return errors.Wrap(err, "failed to glob for public key files")
}
for _, path := range paths {
key, err := readSSHKey(path)
if err != nil {
continue
}
pubKeys[path] = key
continue
}
pubKeys[path] = key
}
}

View File

@@ -1,50 +1,13 @@
package asset
import (
"io/ioutil"
"os"
"github.com/pkg/errors"
survey "gopkg.in/AlecAivazis/survey.v1"
)
// GenerateUserProvidedAsset queries for input from the user.
func GenerateUserProvidedAsset(inputName string, question *survey.Question, envVarName string) (string, error) {
return generateUserProvidedAsset(inputName, question, envVarName, "")
}
// GenerateUserProvidedAssetForPath queries for input from the user. The input can
// be read from a file specified in an environment variable.
func GenerateUserProvidedAssetForPath(inputName string, question *survey.Question, envVarName, pathEnvVarName string) (string, error) {
return generateUserProvidedAsset(inputName, question, envVarName, pathEnvVarName)
}
func generateUserProvidedAsset(inputName string, question *survey.Question, envVarName, pathEnvVarName string) (response string, err error) {
defer func() {
if err != nil {
err = errors.Wrapf(err, "failed to acquire user-provided input %s", inputName)
}
}()
if value, ok := os.LookupEnv(envVarName); ok {
response = value
} else if path, ok := os.LookupEnv(pathEnvVarName); ok {
value, err := ioutil.ReadFile(path)
if err != nil {
return "", errors.Wrapf(err, "failed to read file from %s", pathEnvVarName)
}
response = string(value)
}
if response == "" {
if err := survey.Ask([]*survey.Question{question}, &response); err != nil {
return "", errors.Wrap(err, "failed to Ask")
}
} else if question.Validate != nil {
if err := question.Validate(response); err != nil {
return "", errors.Wrap(err, "validation failed")
}
}
return response, nil
func GenerateUserProvidedAsset(inputName string, question *survey.Question) (string, error) {
var response string
err := survey.Ask([]*survey.Question{question}, &response)
return response, errors.Wrapf(err, "failed to acquire user-provided input %s", inputName)
}