Skip to content

Commit 897fcdd

Browse files
Merge pull request #861 from crawford/env-vars
*: remove support for environment variables
2 parents 7a46568 + e6609b9 commit 897fcdd

File tree

13 files changed

+86
-236
lines changed

13 files changed

+86
-236
lines changed

docs/dev/libvirt-howto.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,15 +223,6 @@ Set `TAGS` when building if you need `destroy cluster` support for libvirt; this
223223
TAGS=libvirt_destroy hack/build.sh
224224
```
225225

226-
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:
227-
228-
```sh
229-
export OPENSHIFT_INSTALL_PLATFORM=libvirt
230-
export OPENSHIFT_INSTALL_BASE_DOMAIN=tt.testing
231-
export OPENSHIFT_INSTALL_CLUSTER_NAME=test1
232-
export OPENSHIFT_INSTALL_LIBVIRT_URI=qemu+tcp://192.168.122.1/system
233-
```
234-
235226
## Cleanup
236227

237228
If you compiled with `libvirt_destroy`, you can use:

docs/user/environment-variables.md

Lines changed: 0 additions & 51 deletions
This file was deleted.

docs/user/tips-and-tricks.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Tips and Tricks
2+
3+
## Reusing an Install Config
4+
5+
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].
6+
7+
Start by creating an install config and saving it in a cluster-agnostic location:
8+
9+
```console
10+
openshift-install create install-config --dir=initial
11+
mv initial/install-config.yml .
12+
rm -rf initial
13+
```
14+
15+
Future clusters can then be created by copying that install config into the target directory and then invoking the installer:
16+
17+
```console
18+
mkdir cluster-0
19+
cp install-config.yml cluster-0/
20+
openshift-install create cluster --dir=cluster-0
21+
```
22+
23+
[multiple-invocations]: overview.md#multiple-invocations

pkg/asset/installconfig/aws/aws.go

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
package aws
33

44
import (
5-
"encoding/json"
65
"fmt"
76
"os"
87
"path/filepath"
@@ -17,7 +16,6 @@ import (
1716
"github.com/sirupsen/logrus"
1817
survey "gopkg.in/AlecAivazis/survey.v1"
1918

20-
"github.com/openshift/installer/pkg/asset"
2119
"github.com/openshift/installer/pkg/types/aws"
2220
)
2321

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

9492
sort.Strings(longRegions)
9593
sort.Strings(shortRegions)
96-
region, err := asset.GenerateUserProvidedAsset(
97-
"AWS Region",
98-
&survey.Question{
94+
95+
var region string
96+
err = survey.Ask([]*survey.Question{
97+
{
9998
Prompt: &survey.Select{
10099
Message: "Region",
101100
Help: "The AWS region to be used for installation.",
@@ -112,51 +111,40 @@ func Platform() (*aws.Platform, error) {
112111
}),
113112
Transform: regionTransform,
114113
},
115-
"OPENSHIFT_INSTALL_AWS_REGION",
116-
)
114+
}, &region)
117115
if err != nil {
118116
return nil, err
119117
}
120118

121-
userTags := map[string]string{}
122-
if value, ok := os.LookupEnv("_CI_ONLY_STAY_AWAY_OPENSHIFT_INSTALL_AWS_USER_TAGS"); ok {
123-
if err := json.Unmarshal([]byte(value), &userTags); err != nil {
124-
return nil, errors.Wrapf(err, "_CI_ONLY_STAY_AWAY_OPENSHIFT_INSTALL_AWS_USER_TAGS contains invalid JSON: %s", value)
125-
}
126-
}
127-
128119
return &aws.Platform{
129120
VPCCIDRBlock: defaultVPCCIDR,
130121
Region: region,
131-
UserTags: userTags,
132122
}, nil
133123
}
134124

135125
func getCredentials() error {
136-
keyID, err := asset.GenerateUserProvidedAsset(
137-
"AWS Access Key ID",
138-
&survey.Question{
126+
var keyID string
127+
err := survey.Ask([]*survey.Question{
128+
{
139129
Prompt: &survey.Input{
140130
Message: "AWS Access Key ID",
141131
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",
142132
},
143133
},
144-
"",
145-
)
134+
}, keyID)
146135
if err != nil {
147136
return err
148137
}
149138

150-
secretKey, err := asset.GenerateUserProvidedAsset(
151-
"AWS Access Key ID",
152-
&survey.Question{
139+
var secretKey string
140+
err = survey.Ask([]*survey.Question{
141+
{
153142
Prompt: &survey.Password{
154143
Message: "AWS Secret Access Key",
155144
Help: "The AWS secret access key corresponding to your access key ID (this is not your password).",
156145
},
157146
},
158-
"",
159-
)
147+
}, &secretKey)
160148
if err != nil {
161149
return err
162150
}

pkg/asset/installconfig/basedomain.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ func (a *baseDomain) Dependencies() []asset.Asset {
2020

2121
// Generate queries for the base domain from the user.
2222
func (a *baseDomain) Generate(asset.Parents) error {
23-
bd, err := asset.GenerateUserProvidedAsset(
24-
a.Name(),
25-
&survey.Question{
23+
return survey.Ask([]*survey.Question{
24+
{
2625
Prompt: &survey.Input{
2726
Message: "Base Domain",
2827
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",
@@ -31,10 +30,7 @@ func (a *baseDomain) Generate(asset.Parents) error {
3130
return validate.DomainName(ans.(string))
3231
}),
3332
},
34-
"OPENSHIFT_INSTALL_BASE_DOMAIN",
35-
)
36-
a.BaseDomain = bd
37-
return err
33+
}, &a.BaseDomain)
3834
}
3935

4036
// Name returns the human-friendly name of the asset.

pkg/asset/installconfig/clustername.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ func (a *clusterName) Dependencies() []asset.Asset {
2020

2121
// Generate queries for the cluster name from the user.
2222
func (a *clusterName) Generate(asset.Parents) error {
23-
n, err := asset.GenerateUserProvidedAsset(
24-
a.Name(),
25-
&survey.Question{
23+
return survey.Ask([]*survey.Question{
24+
{
2625
Prompt: &survey.Input{
2726
Message: "Cluster Name",
2827
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'.",
@@ -31,10 +30,7 @@ func (a *clusterName) Generate(asset.Parents) error {
3130
return validate.DomainName(ans.(string))
3231
}),
3332
},
34-
"OPENSHIFT_INSTALL_CLUSTER_NAME",
35-
)
36-
a.ClusterName = n
37-
return err
33+
}, &a.ClusterName)
3834
}
3935

4036
// Name returns the human-friendly name of the asset.

pkg/asset/installconfig/emailaddress.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ func (a *emailAddress) Dependencies() []asset.Asset {
2020

2121
// Generate queries for the email address from the user.
2222
func (a *emailAddress) Generate(asset.Parents) error {
23-
email, err := asset.GenerateUserProvidedAsset(
24-
a.Name(),
25-
&survey.Question{
23+
return survey.Ask([]*survey.Question{
24+
{
2625
Prompt: &survey.Input{
2726
Message: "Email Address",
2827
Help: "The email address of the cluster administrator. This will be used to log in to the console.",
@@ -31,10 +30,7 @@ func (a *emailAddress) Generate(asset.Parents) error {
3130
return validate.Email(ans.(string))
3231
}),
3332
},
34-
"OPENSHIFT_INSTALL_EMAIL_ADDRESS",
35-
)
36-
a.EmailAddress = email
37-
return err
33+
}, &a.EmailAddress)
3834
}
3935

4036
// Name returns the human-friendly name of the asset.

pkg/asset/installconfig/libvirt/libvirt.go

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ import (
55
"context"
66
"fmt"
77
"net/url"
8-
"os"
98

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

13-
"github.com/openshift/installer/pkg/asset"
1412
"github.com/openshift/installer/pkg/rhcos"
1513
"github.com/openshift/installer/pkg/types/libvirt"
1614
)
@@ -22,33 +20,24 @@ const (
2220

2321
// Platform collects libvirt-specific configuration.
2422
func Platform() (*libvirt.Platform, error) {
25-
uri, err := asset.GenerateUserProvidedAsset(
26-
"Libvirt Connection URI",
27-
&survey.Question{
23+
var uri string
24+
err := survey.Ask([]*survey.Question{
25+
{
2826
Prompt: &survey.Input{
2927
Message: "Libvirt Connection URI",
3028
Help: "The libvirt connection URI to be used. This must be accessible from the running cluster.",
3129
Default: "qemu+tcp://192.168.122.1/system",
3230
},
3331
Validate: survey.ComposeValidators(survey.Required, uriValidator),
3432
},
35-
"OPENSHIFT_INSTALL_LIBVIRT_URI",
36-
)
33+
}, &uri)
3734
if err != nil {
3835
return nil, err
3936
}
4037

41-
qcowImage, ok := os.LookupEnv("OPENSHIFT_INSTALL_LIBVIRT_IMAGE")
42-
if ok {
43-
err = validURI(qcowImage)
44-
if err != nil {
45-
return nil, errors.Wrap(err, "resolve OPENSHIFT_INSTALL_LIBVIRT_IMAGE")
46-
}
47-
} else {
48-
qcowImage, err = rhcos.QEMU(context.TODO(), rhcos.DefaultChannel)
49-
if err != nil {
50-
return nil, errors.Wrap(err, "failed to fetch QEMU image URL")
51-
}
38+
qcowImage, err := rhcos.QEMU(context.TODO(), rhcos.DefaultChannel)
39+
if err != nil {
40+
return nil, errors.Wrap(err, "failed to fetch QEMU image URL")
5241
}
5342

5443
return &libvirt.Platform{

0 commit comments

Comments
 (0)