Skip to content

*: remove support for environment variables #861

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 12, 2018
Merged
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
9 changes: 0 additions & 9 deletions docs/dev/libvirt-howto.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
51 changes: 0 additions & 51 deletions docs/user/environment-variables.md

This file was deleted.

23 changes: 23 additions & 0 deletions docs/user/tips-and-tricks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Tips and Tricks

## Reusing an Install Config

By default, the installer prompts for the necessary information every time a cluster is created. While convenient for one-off cases, this can become tiring if many clusters are needed. The prompts can be bypassed by taking advantage of the installer's notion of [multiple-invocations].

Start by creating an install config and saving it in a cluster-agnostic location:

```console
openshift-install create install-config --dir=initial
mv initial/install-config.yml .
rm -rf initial
```

Future clusters can then be created by copying that install config into the target directory and then invoking the installer:

```console
mkdir cluster-0
cp install-config.yml cluster-0/
openshift-install create cluster --dir=cluster-0
```

[multiple-invocations]: overview.md#multiple-invocations
38 changes: 13 additions & 25 deletions pkg/asset/installconfig/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
package aws

import (
"encoding/json"
"fmt"
"os"
"path/filepath"
Expand All @@ -17,7 +16,6 @@ import (
"github.com/sirupsen/logrus"
survey "gopkg.in/AlecAivazis/survey.v1"

"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/types/aws"
)

Expand Down Expand Up @@ -93,9 +91,10 @@ func Platform() (*aws.Platform, error) {

sort.Strings(longRegions)
sort.Strings(shortRegions)
region, err := asset.GenerateUserProvidedAsset(
"AWS Region",
&survey.Question{

var region string
err = survey.Ask([]*survey.Question{
{
Prompt: &survey.Select{
Message: "Region",
Help: "The AWS region to be used for installation.",
Expand All @@ -112,51 +111,40 @@ func Platform() (*aws.Platform, error) {
}),
Transform: regionTransform,
},
"OPENSHIFT_INSTALL_AWS_REGION",
)
}, &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
}

func getCredentials() error {
keyID, err := asset.GenerateUserProvidedAsset(
"AWS Access Key ID",
&survey.Question{
var keyID string
err := survey.Ask([]*survey.Question{
{
Prompt: &survey.Input{
Message: "AWS Access Key ID",
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",
},
},
"",
)
}, keyID)
if err != nil {
return err
}

secretKey, err := asset.GenerateUserProvidedAsset(
"AWS Access Key ID",
&survey.Question{
var secretKey string
err = survey.Ask([]*survey.Question{
{
Prompt: &survey.Password{
Message: "AWS Secret Access Key",
Help: "The AWS secret access key corresponding to your access key ID (this is not your password).",
},
},
"",
)
}, &secretKey)
if err != nil {
return err
}
Expand Down
10 changes: 3 additions & 7 deletions pkg/asset/installconfig/basedomain.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ func (a *baseDomain) Dependencies() []asset.Asset {

// Generate queries for the base domain from the user.
func (a *baseDomain) Generate(asset.Parents) error {
bd, err := asset.GenerateUserProvidedAsset(
a.Name(),
&survey.Question{
return survey.Ask([]*survey.Question{
{
Prompt: &survey.Input{
Message: "Base Domain",
Help: "The base domain of the cluster. All DNS records will be sub-domains of this base and will also include the cluster name.\n\nFor AWS, this must be a previously-existing public Route 53 zone. You can check for any already in your account with:\n\n $ aws route53 list-hosted-zones --query 'HostedZones[? !(Config.PrivateZone)].Name' --output text",
Expand All @@ -31,10 +30,7 @@ func (a *baseDomain) Generate(asset.Parents) error {
return validate.DomainName(ans.(string))
}),
},
"OPENSHIFT_INSTALL_BASE_DOMAIN",
)
a.BaseDomain = bd
return err
}, &a.BaseDomain)
}

// Name returns the human-friendly name of the asset.
Expand Down
10 changes: 3 additions & 7 deletions pkg/asset/installconfig/clustername.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ func (a *clusterName) Dependencies() []asset.Asset {

// Generate queries for the cluster name from the user.
func (a *clusterName) Generate(asset.Parents) error {
n, err := asset.GenerateUserProvidedAsset(
a.Name(),
&survey.Question{
return survey.Ask([]*survey.Question{
{
Prompt: &survey.Input{
Message: "Cluster Name",
Help: "The name of the cluster. This will be used when generating sub-domains.\n\nFor 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'.",
Expand All @@ -31,10 +30,7 @@ func (a *clusterName) Generate(asset.Parents) error {
return validate.DomainName(ans.(string))
}),
},
"OPENSHIFT_INSTALL_CLUSTER_NAME",
)
a.ClusterName = n
return err
}, &a.ClusterName)
}

// Name returns the human-friendly name of the asset.
Expand Down
10 changes: 3 additions & 7 deletions pkg/asset/installconfig/emailaddress.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ func (a *emailAddress) Dependencies() []asset.Asset {

// Generate queries for the email address from the user.
func (a *emailAddress) Generate(asset.Parents) error {
email, err := asset.GenerateUserProvidedAsset(
a.Name(),
&survey.Question{
return survey.Ask([]*survey.Question{
{
Prompt: &survey.Input{
Message: "Email Address",
Help: "The email address of the cluster administrator. This will be used to log in to the console.",
Expand All @@ -31,10 +30,7 @@ func (a *emailAddress) Generate(asset.Parents) error {
return validate.Email(ans.(string))
}),
},
"OPENSHIFT_INSTALL_EMAIL_ADDRESS",
)
a.EmailAddress = email
return err
}, &a.EmailAddress)
}

// Name returns the human-friendly name of the asset.
Expand Down
25 changes: 7 additions & 18 deletions pkg/asset/installconfig/libvirt/libvirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ import (
"context"
"fmt"
"net/url"
"os"

"github.com/pkg/errors"
survey "gopkg.in/AlecAivazis/survey.v1"

"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/rhcos"
"github.com/openshift/installer/pkg/types/libvirt"
)
Expand All @@ -22,33 +20,24 @@ const (

// Platform collects libvirt-specific configuration.
func Platform() (*libvirt.Platform, error) {
uri, err := asset.GenerateUserProvidedAsset(
"Libvirt Connection URI",
&survey.Question{
var uri string
err := survey.Ask([]*survey.Question{
{
Prompt: &survey.Input{
Message: "Libvirt Connection URI",
Help: "The libvirt connection URI to be used. This must be accessible from the running cluster.",
Default: "qemu+tcp://192.168.122.1/system",
},
Validate: survey.ComposeValidators(survey.Required, uriValidator),
},
"OPENSHIFT_INSTALL_LIBVIRT_URI",
)
}, &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{
Expand Down
Loading