1
0
mirror of https://github.com/rancher/os.git synced 2025-06-27 07:16:48 +00:00

Merge pull request #1846 from SvenDowideit/simplify-cloud-init

Add a default for configdrive, and add '*' to scan all defaultable da…
This commit is contained in:
Sven Dowideit 2017-06-05 15:48:05 +10:00 committed by GitHub
commit ef7c16d4d4
2 changed files with 12 additions and 8 deletions

View File

@ -72,7 +72,7 @@ func saveCloudConfig() error {
network.ApplyNetworkConfig(cfg)
log.Debugf("datasources that will be consided: %#v", cfg.Rancher.CloudInit.Datasources)
dss := getDatasources(cfg)
dss := getDatasources(cfg.Rancher.CloudInit.Datasources)
if len(dss) == 0 {
log.Errorf("currentDatasource - none found")
return nil
@ -216,10 +216,10 @@ func fetchAndSave(ds datasource.Datasource) error {
// getDatasources creates a slice of possible Datasources for cloudinit based
// on the different source command-line flags.
func getDatasources(cfg *rancherConfig.CloudConfig) []datasource.Datasource {
func getDatasources(datasources []string) []datasource.Datasource {
dss := make([]datasource.Datasource, 0, 5)
for _, ds := range cfg.Rancher.CloudInit.Datasources {
for _, ds := range datasources {
parts := strings.SplitN(ds, ":", 2)
root := ""
@ -228,6 +228,8 @@ func getDatasources(cfg *rancherConfig.CloudConfig) []datasource.Datasource {
}
switch parts[0] {
case "*":
dss = append(dss, getDatasources([]string{"configdrive", "ec2", "digitalocean", "packet", "gce"})...)
case "ec2":
dss = append(dss, ec2.NewDatasource(root))
case "file":
@ -243,9 +245,10 @@ func getDatasources(cfg *rancherConfig.CloudConfig) []datasource.Datasource {
dss = append(dss, proccmdline.NewDatasource())
}
case "configdrive":
if root != "" {
dss = append(dss, configdrive.NewDatasource(root))
if root == "" {
root = "/media/config-2"
}
dss = append(dss, configdrive.NewDatasource(root))
case "digitalocean":
// TODO: should we enableDoLinkLocal() - to avoid the need for the other kernel/oem options?
dss = append(dss, digitalocean.NewDatasource(root))

View File

@ -51,10 +51,10 @@ When this service is run, the `EXTRA_CMDLINE` will be set.
Valid cloud-init datasources for RancherOS.
| type | default |
|---|---|
| ec2 | DefaultAddress |
|---|---|--|
| ec2 | ec2's DefaultAddress |
| file | path |
| cmdline | |
| cmdline | /media/config-2 |
| configdrive | |
| digitalocean | DefaultAddress |
| ec2 | DefaultAddress |
@ -62,6 +62,7 @@ Valid cloud-init datasources for RancherOS.
| gce | |
| packet | DefaultAddress |
| url | url |
| * | This will add ["configdrive", "ec2", "digitalocean", "packet", "gce"] into the list of datasources to try |
### Cloud-Config