mirror of
https://github.com/rancher/os.git
synced 2025-06-27 15:26:50 +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:
commit
ef7c16d4d4
@ -72,7 +72,7 @@ func saveCloudConfig() error {
|
|||||||
network.ApplyNetworkConfig(cfg)
|
network.ApplyNetworkConfig(cfg)
|
||||||
|
|
||||||
log.Debugf("datasources that will be consided: %#v", cfg.Rancher.CloudInit.Datasources)
|
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 {
|
if len(dss) == 0 {
|
||||||
log.Errorf("currentDatasource - none found")
|
log.Errorf("currentDatasource - none found")
|
||||||
return nil
|
return nil
|
||||||
@ -216,10 +216,10 @@ func fetchAndSave(ds datasource.Datasource) error {
|
|||||||
|
|
||||||
// getDatasources creates a slice of possible Datasources for cloudinit based
|
// getDatasources creates a slice of possible Datasources for cloudinit based
|
||||||
// on the different source command-line flags.
|
// 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)
|
dss := make([]datasource.Datasource, 0, 5)
|
||||||
|
|
||||||
for _, ds := range cfg.Rancher.CloudInit.Datasources {
|
for _, ds := range datasources {
|
||||||
parts := strings.SplitN(ds, ":", 2)
|
parts := strings.SplitN(ds, ":", 2)
|
||||||
|
|
||||||
root := ""
|
root := ""
|
||||||
@ -228,6 +228,8 @@ func getDatasources(cfg *rancherConfig.CloudConfig) []datasource.Datasource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch parts[0] {
|
switch parts[0] {
|
||||||
|
case "*":
|
||||||
|
dss = append(dss, getDatasources([]string{"configdrive", "ec2", "digitalocean", "packet", "gce"})...)
|
||||||
case "ec2":
|
case "ec2":
|
||||||
dss = append(dss, ec2.NewDatasource(root))
|
dss = append(dss, ec2.NewDatasource(root))
|
||||||
case "file":
|
case "file":
|
||||||
@ -243,9 +245,10 @@ func getDatasources(cfg *rancherConfig.CloudConfig) []datasource.Datasource {
|
|||||||
dss = append(dss, proccmdline.NewDatasource())
|
dss = append(dss, proccmdline.NewDatasource())
|
||||||
}
|
}
|
||||||
case "configdrive":
|
case "configdrive":
|
||||||
if root != "" {
|
if root == "" {
|
||||||
dss = append(dss, configdrive.NewDatasource(root))
|
root = "/media/config-2"
|
||||||
}
|
}
|
||||||
|
dss = append(dss, configdrive.NewDatasource(root))
|
||||||
case "digitalocean":
|
case "digitalocean":
|
||||||
// TODO: should we enableDoLinkLocal() - to avoid the need for the other kernel/oem options?
|
// TODO: should we enableDoLinkLocal() - to avoid the need for the other kernel/oem options?
|
||||||
dss = append(dss, digitalocean.NewDatasource(root))
|
dss = append(dss, digitalocean.NewDatasource(root))
|
||||||
|
@ -51,10 +51,10 @@ When this service is run, the `EXTRA_CMDLINE` will be set.
|
|||||||
Valid cloud-init datasources for RancherOS.
|
Valid cloud-init datasources for RancherOS.
|
||||||
|
|
||||||
| type | default |
|
| type | default |
|
||||||
|---|---|
|
|---|---|--|
|
||||||
| ec2 | DefaultAddress |
|
| ec2 | ec2's DefaultAddress |
|
||||||
| file | path |
|
| file | path |
|
||||||
| cmdline | |
|
| cmdline | /media/config-2 |
|
||||||
| configdrive | |
|
| configdrive | |
|
||||||
| digitalocean | DefaultAddress |
|
| digitalocean | DefaultAddress |
|
||||||
| ec2 | DefaultAddress |
|
| ec2 | DefaultAddress |
|
||||||
@ -62,6 +62,7 @@ Valid cloud-init datasources for RancherOS.
|
|||||||
| gce | |
|
| gce | |
|
||||||
| packet | DefaultAddress |
|
| packet | DefaultAddress |
|
||||||
| url | url |
|
| url | url |
|
||||||
|
| * | This will add ["configdrive", "ec2", "digitalocean", "packet", "gce"] into the list of datasources to try |
|
||||||
|
|
||||||
### Cloud-Config
|
### Cloud-Config
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user