Permalink
Browse files

Move default hostname and network under common key

  • Loading branch information...
1 parent 97344cc commit e51c5409aa067227ec53ed06b4b6ed255abe3fbd @joshwget joshwget committed May 3, 2016
Showing with 18 additions and 11 deletions.
  1. +2 −2 cmd/network/network.go
  2. +6 −1 config/types.go
  3. +3 −2 hostname/hostname.go
  4. +2 −2 init/init.go
  5. +5 −4 os-config.tpl.yml
@@ -56,8 +56,8 @@ func Main() {
search := cfg.Rancher.Network.Dns.Search
userSetDns := len(nameservers) > 0 || len(search) > 0
if !userSetDns {
- nameservers = cfg.Rancher.DefaultNetwork.Dns.Nameservers
- search = cfg.Rancher.DefaultNetwork.Dns.Search
+ nameservers = cfg.Rancher.Defaults.Network.Dns.Nameservers
+ search = cfg.Rancher.Defaults.Network.Dns.Search
}
if _, err := resolvconf.Build("/etc/resolv.conf", nameservers, search, nil); err != nil {
View
@@ -78,7 +78,6 @@ type CloudConfig struct {
SSHAuthorizedKeys []string `yaml:"ssh_authorized_keys"`
WriteFiles []config.File `yaml:"write_files"`
Hostname string `yaml:"hostname"`
- DefaultHostname string `yaml:"default_hostname"`
Rancher RancherConfig `yaml:"rancher,omitempty"`
}
@@ -105,6 +104,7 @@ type RancherConfig struct {
SystemDocker DockerConfig `yaml:"system_docker,omitempty"`
Upgrade UpgradeConfig `yaml:"upgrade,omitempty"`
Docker DockerConfig `yaml:"docker,omitempty"`
+ Defaults Defaults `yaml:"defaults,omitempty"`
}
type UpgradeConfig struct {
@@ -148,6 +148,11 @@ type CloudInit struct {
Datasources []string `yaml:"datasources,omitempty"`
}
+type Defaults struct {
+ Hostname string `yaml:"hostname,omitempty"`
+ Network netconf.NetworkConfig `yaml:"network,omitempty"`
+}
+
func (r Repositories) ToArray() []string {
result := make([]string, 0, len(r))
for _, repo := range r {
@@ -2,17 +2,18 @@ package hostname
import (
"bufio"
- "github.com/rancher/os/config"
"io/ioutil"
"os"
"strings"
"syscall"
+
+ "github.com/rancher/os/config"
)
func SetHostnameFromCloudConfig(cc *config.CloudConfig) error {
var hostname string
if cc.Hostname == "" {
- hostname = cc.DefaultHostname
+ hostname = cc.Rancher.Defaults.Hostname
} else {
hostname = cc.Hostname
}
View
@@ -164,8 +164,8 @@ func getLaunchConfig(cfg *config.CloudConfig, dockerCfg *config.DockerConfig) (*
args := dockerlaunch.ParseConfig(&launchConfig, append(dockerCfg.Args, dockerCfg.ExtraArgs...)...)
- launchConfig.DnsConfig.Nameservers = cfg.Rancher.DefaultNetwork.Dns.Nameservers
- launchConfig.DnsConfig.Search = cfg.Rancher.DefaultNetwork.Dns.Search
+ launchConfig.DnsConfig.Nameservers = cfg.Rancher.Defaults.Network.Dns.Nameservers
+ launchConfig.DnsConfig.Search = cfg.Rancher.Defaults.Network.Dns.Search
launchConfig.Environment = dockerCfg.Environment
launchConfig.EmulateSystemd = true
View
@@ -1,5 +1,9 @@
-default_hostname: {{.HOSTNAME_DEFAULT}}
rancher:
+ defaults:
+ hostname: {{.HOSTNAME_DEFAULT}}
+ network:
+ dns:
+ nameservers: [8.8.8.8, 8.8.4.4]
bootstrap:
state-script:
image: {{.OS_REPO}}/os-statescript:{{.VERSION}}{{.SUFFIX}}
@@ -61,9 +65,6 @@ rancher:
cloud_init:
datasources:
- configdrive:/media/config-2
- default_network:
- dns:
- nameservers: [8.8.8.8, 8.8.4.4]
repositories:
core:
url: {{.OS_SERVICES_REPO}}/{{.REPO_VERSION}}{{.SUFFIX}}

0 comments on commit e51c540

Please sign in to comment.