2015-03-15 04:27:04 +00:00
|
|
|
package config
|
|
|
|
|
2015-07-29 06:52:15 +00:00
|
|
|
import (
|
2016-06-28 21:22:13 +00:00
|
|
|
"fmt"
|
2016-05-24 00:21:28 +00:00
|
|
|
"runtime"
|
|
|
|
|
2017-02-23 01:29:01 +00:00
|
|
|
"github.com/rancher/os/config/cloudinit/config"
|
2016-11-07 19:36:37 +00:00
|
|
|
"github.com/rancher/os/config/yaml"
|
2018-09-16 04:55:26 +00:00
|
|
|
"github.com/rancher/os/pkg/netconf"
|
2018-10-23 04:13:32 +00:00
|
|
|
|
|
|
|
"github.com/docker/engine-api/types"
|
|
|
|
composeConfig "github.com/docker/libcompose/config"
|
2015-07-29 06:52:15 +00:00
|
|
|
)
|
2015-03-29 09:57:15 +00:00
|
|
|
|
2015-03-15 04:27:04 +00:00
|
|
|
const (
|
2018-09-30 06:30:25 +00:00
|
|
|
OemDir = "/usr/share/ros/oem"
|
|
|
|
BootDir = "/boot"
|
|
|
|
StateDir = "/state"
|
2016-11-28 08:06:00 +00:00
|
|
|
RosBin = "/usr/bin/ros"
|
|
|
|
SysInitBin = "/usr/bin/ros-sysinit"
|
|
|
|
SystemDockerHost = "unix:///var/run/system-docker.sock"
|
|
|
|
DockerHost = "unix:///var/run/docker.sock"
|
|
|
|
ImagesPath = "/usr/share/ros"
|
2018-09-09 08:07:50 +00:00
|
|
|
InitImages = "images-init.tar"
|
|
|
|
SystemImages = "images-system.tar"
|
2019-05-16 06:11:17 +00:00
|
|
|
UserImages = "images-user.tar"
|
2016-11-28 08:06:00 +00:00
|
|
|
Debug = false
|
2018-02-27 09:55:59 +00:00
|
|
|
SystemDockerBin = "/usr/bin/system-dockerd"
|
2018-12-13 02:24:08 +00:00
|
|
|
DefaultDind = "rancher/os-dind:17.12.1"
|
2016-11-28 08:06:00 +00:00
|
|
|
|
2018-06-27 04:08:32 +00:00
|
|
|
DetachLabel = "io.rancher.os.detach"
|
|
|
|
CreateOnlyLabel = "io.rancher.os.createonly"
|
|
|
|
ReloadConfigLabel = "io.rancher.os.reloadconfig"
|
|
|
|
ConsoleLabel = "io.rancher.os.console"
|
|
|
|
ScopeLabel = "io.rancher.os.scope"
|
|
|
|
RebuildLabel = "io.docker.compose.rebuild"
|
|
|
|
UserDockerLabel = "io.rancher.user_docker.name"
|
|
|
|
UserDockerNetLabel = "io.rancher.user_docker.net"
|
|
|
|
UserDockerFIPLabel = "io.rancher.user_docker.fix_ip"
|
|
|
|
System = "system"
|
2015-07-29 06:52:15 +00:00
|
|
|
|
2015-09-23 11:36:28 +00:00
|
|
|
OsConfigFile = "/usr/share/ros/os-config.yml"
|
2017-03-13 07:17:15 +00:00
|
|
|
VarRancherDir = "/var/lib/rancher"
|
2015-09-23 11:36:28 +00:00
|
|
|
CloudConfigDir = "/var/lib/rancher/conf/cloud-config.d"
|
2017-03-10 14:23:22 +00:00
|
|
|
CloudConfigInitFile = "/var/lib/rancher/conf/cloud-config.d/init.yml"
|
2015-09-23 11:36:28 +00:00
|
|
|
CloudConfigBootFile = "/var/lib/rancher/conf/cloud-config.d/boot.yml"
|
2015-12-20 05:37:57 +00:00
|
|
|
CloudConfigNetworkFile = "/var/lib/rancher/conf/cloud-config.d/network.yml"
|
2015-09-23 11:36:28 +00:00
|
|
|
CloudConfigScriptFile = "/var/lib/rancher/conf/cloud-config-script"
|
|
|
|
MetaDataFile = "/var/lib/rancher/conf/metadata"
|
|
|
|
CloudConfigFile = "/var/lib/rancher/conf/cloud-config.yml"
|
2017-08-28 04:22:50 +00:00
|
|
|
EtcResolvConfFile = "/etc/resolv.conf"
|
2018-11-07 09:04:45 +00:00
|
|
|
WPAConfigFile = "/etc/wpa_supplicant-%s.conf"
|
|
|
|
WPATemplateFile = "/etc/wpa_supplicant.conf.tpl"
|
|
|
|
DHCPCDConfigFile = "/etc/dhcpcd.conf"
|
|
|
|
DHCPCDTemplateFile = "/etc/dhcpcd.conf.tpl"
|
2018-06-27 04:08:32 +00:00
|
|
|
MultiDockerConfFile = "/var/lib/rancher/conf.d/m-user-docker.yml"
|
|
|
|
MultiDockerDataDir = "/var/lib/m-user-docker"
|
2018-11-29 08:41:52 +00:00
|
|
|
UdevRulesDir = "/etc/udev/rules.d"
|
|
|
|
UdevRulesExtrasDir = "/lib/udev/rules-extras.d"
|
2015-03-15 04:27:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2018-09-30 06:30:25 +00:00
|
|
|
OemConfigFile = OemDir + "/oem-config.yml"
|
2016-11-28 08:06:00 +00:00
|
|
|
Version string
|
2017-07-28 01:50:07 +00:00
|
|
|
BuildDate string
|
2016-11-28 08:06:00 +00:00
|
|
|
Arch string
|
|
|
|
Suffix string
|
|
|
|
OsRepo string
|
|
|
|
OsBase string
|
2016-05-31 21:34:04 +00:00
|
|
|
PrivateKeys = []string{
|
|
|
|
"rancher.ssh",
|
|
|
|
"rancher.docker.ca_key",
|
|
|
|
"rancher.docker.ca_cert",
|
|
|
|
"rancher.docker.server_key",
|
|
|
|
"rancher.docker.server_cert",
|
|
|
|
}
|
2018-05-02 06:21:57 +00:00
|
|
|
Additional = []string{
|
|
|
|
"rancher.password",
|
|
|
|
"rancher.autologin",
|
|
|
|
"EXTRA_CMDLINE",
|
|
|
|
}
|
2018-12-13 02:24:08 +00:00
|
|
|
SupportedDinds = []string{
|
|
|
|
"rancher/os-dind:17.12.1",
|
|
|
|
"rancher/os-dind:18.03.1",
|
|
|
|
}
|
2015-03-15 04:27:04 +00:00
|
|
|
)
|
|
|
|
|
2015-09-23 11:36:28 +00:00
|
|
|
func init() {
|
2016-11-28 08:06:00 +00:00
|
|
|
if Version == "" {
|
|
|
|
Version = "v0.0.0-dev"
|
2015-09-23 11:36:28 +00:00
|
|
|
}
|
2016-11-28 08:06:00 +00:00
|
|
|
if Arch == "" {
|
|
|
|
Arch = runtime.GOARCH
|
2016-03-28 20:50:29 +00:00
|
|
|
}
|
2016-11-28 08:06:00 +00:00
|
|
|
if Suffix == "" && Arch != "amd64" {
|
|
|
|
Suffix = "_" + Arch
|
2016-03-28 20:50:29 +00:00
|
|
|
}
|
2016-11-28 08:06:00 +00:00
|
|
|
if OsBase == "" {
|
|
|
|
OsBase = fmt.Sprintf("%s/os-base:%s%s", OsRepo, Version, Suffix)
|
2016-06-28 21:22:13 +00:00
|
|
|
}
|
2015-09-23 11:36:28 +00:00
|
|
|
}
|
|
|
|
|
2015-04-16 05:57:59 +00:00
|
|
|
type Repository struct {
|
2016-11-28 08:06:00 +00:00
|
|
|
URL string `yaml:"url,omitempty"`
|
2015-04-16 05:57:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Repositories map[string]Repository
|
|
|
|
|
2015-07-29 06:52:15 +00:00
|
|
|
type CloudConfig struct {
|
2017-03-10 14:23:22 +00:00
|
|
|
SSHAuthorizedKeys []string `yaml:"ssh_authorized_keys,omitempty"`
|
|
|
|
WriteFiles []File `yaml:"write_files,omitempty"`
|
|
|
|
Hostname string `yaml:"hostname,omitempty"`
|
2016-11-07 19:36:37 +00:00
|
|
|
Mounts [][]string `yaml:"mounts,omitempty"`
|
|
|
|
Rancher RancherConfig `yaml:"rancher,omitempty"`
|
|
|
|
Runcmd []yaml.StringandSlice `yaml:"runcmd,omitempty"`
|
|
|
|
Bootcmd []yaml.StringandSlice `yaml:"bootcmd,omitempty"`
|
2015-07-29 06:52:15 +00:00
|
|
|
}
|
|
|
|
|
2016-08-15 02:17:24 +00:00
|
|
|
type File struct {
|
|
|
|
config.File
|
|
|
|
Container string `yaml:"container,omitempty"`
|
|
|
|
}
|
|
|
|
|
2015-07-29 06:52:15 +00:00
|
|
|
type RancherConfig struct {
|
2016-06-06 22:13:15 +00:00
|
|
|
Console string `yaml:"console,omitempty"`
|
2016-05-24 00:21:28 +00:00
|
|
|
Environment map[string]string `yaml:"environment,omitempty"`
|
|
|
|
Services map[string]*composeConfig.ServiceConfigV1 `yaml:"services,omitempty"`
|
|
|
|
BootstrapContainers map[string]*composeConfig.ServiceConfigV1 `yaml:"bootstrap,omitempty"`
|
2016-11-09 19:08:30 +00:00
|
|
|
CloudInitServices map[string]*composeConfig.ServiceConfigV1 `yaml:"cloud_init_services,omitempty"`
|
2016-05-24 00:21:28 +00:00
|
|
|
BootstrapDocker DockerConfig `yaml:"bootstrap_docker,omitempty"`
|
|
|
|
CloudInit CloudInit `yaml:"cloud_init,omitempty"`
|
|
|
|
Debug bool `yaml:"debug,omitempty"`
|
|
|
|
RmUsr bool `yaml:"rm_usr,omitempty"`
|
2016-06-15 23:41:42 +00:00
|
|
|
NoSharedRoot bool `yaml:"no_sharedroot,omitempty"`
|
2016-05-24 00:21:28 +00:00
|
|
|
Log bool `yaml:"log,omitempty"`
|
|
|
|
ForceConsoleRebuild bool `yaml:"force_console_rebuild,omitempty"`
|
2016-11-30 01:06:23 +00:00
|
|
|
Recovery bool `yaml:"recovery,omitempty"`
|
2016-05-24 00:21:28 +00:00
|
|
|
Disable []string `yaml:"disable,omitempty"`
|
|
|
|
ServicesInclude map[string]bool `yaml:"services_include,omitempty"`
|
|
|
|
Modules []string `yaml:"modules,omitempty"`
|
2017-03-07 03:21:14 +00:00
|
|
|
Network netconf.NetworkConfig `yaml:"network,omitempty"`
|
2016-05-24 00:21:28 +00:00
|
|
|
Repositories Repositories `yaml:"repositories,omitempty"`
|
2016-11-28 08:06:00 +00:00
|
|
|
SSH SSHConfig `yaml:"ssh,omitempty"`
|
2016-05-24 00:21:28 +00:00
|
|
|
State StateConfig `yaml:"state,omitempty"`
|
|
|
|
SystemDocker DockerConfig `yaml:"system_docker,omitempty"`
|
|
|
|
Upgrade UpgradeConfig `yaml:"upgrade,omitempty"`
|
|
|
|
Docker DockerConfig `yaml:"docker,omitempty"`
|
2016-05-27 23:09:03 +00:00
|
|
|
RegistryAuths map[string]types.AuthConfig `yaml:"registry_auths,omitempty"`
|
2016-05-03 15:55:15 +00:00
|
|
|
Defaults Defaults `yaml:"defaults,omitempty"`
|
2016-06-07 16:53:41 +00:00
|
|
|
ResizeDevice string `yaml:"resize_device,omitempty"`
|
2016-06-18 06:05:45 +00:00
|
|
|
Sysctl map[string]string `yaml:"sysctl,omitempty"`
|
2016-08-15 02:17:24 +00:00
|
|
|
RestartServices []string `yaml:"restart_services,omitempty"`
|
2017-07-17 11:14:45 +00:00
|
|
|
HypervisorService bool `yaml:"hypervisor_service,omitempty"`
|
2017-07-28 03:27:40 +00:00
|
|
|
ShutdownTimeout int `yaml:"shutdown_timeout,omitempty"`
|
2019-12-19 07:03:05 +00:00
|
|
|
HTTPLoadRetries int `yaml:"http_load_retries,omitempty"`
|
2018-04-02 04:56:47 +00:00
|
|
|
PreloadWait bool `yaml:"preload_wait,omitempty"`
|
2015-03-15 05:21:22 +00:00
|
|
|
}
|
|
|
|
|
2015-03-15 04:27:04 +00:00
|
|
|
type UpgradeConfig struct {
|
2016-11-28 08:06:00 +00:00
|
|
|
URL string `yaml:"url,omitempty"`
|
2015-03-19 21:57:53 +00:00
|
|
|
Image string `yaml:"image,omitempty"`
|
|
|
|
Rollback string `yaml:"rollback,omitempty"`
|
2019-01-30 05:32:08 +00:00
|
|
|
Policy string `yaml:"policy,omitempty"`
|
2015-03-15 04:27:04 +00:00
|
|
|
}
|
|
|
|
|
2016-09-26 00:55:19 +00:00
|
|
|
type EngineOpts struct {
|
2016-11-09 19:36:51 +00:00
|
|
|
Bridge string `yaml:"bridge,omitempty" opt:"bridge"`
|
2018-04-16 06:16:08 +00:00
|
|
|
BIP string `yaml:"bip,omitempty" opt:"bip"`
|
2016-11-09 19:36:51 +00:00
|
|
|
ConfigFile string `yaml:"config_file,omitempty" opt:"config-file"`
|
|
|
|
Containerd string `yaml:"containerd,omitempty" opt:"containerd"`
|
|
|
|
Debug *bool `yaml:"debug,omitempty" opt:"debug"`
|
|
|
|
ExecRoot string `yaml:"exec_root,omitempty" opt:"exec-root"`
|
|
|
|
Group string `yaml:"group,omitempty" opt:"group"`
|
|
|
|
Graph string `yaml:"graph,omitempty" opt:"graph"`
|
|
|
|
Host []string `yaml:"host,omitempty" opt:"host"`
|
|
|
|
InsecureRegistry []string `yaml:"insecure_registry" opt:"insecure-registry"`
|
|
|
|
LiveRestore *bool `yaml:"live_restore,omitempty" opt:"live-restore"`
|
|
|
|
LogDriver string `yaml:"log_driver,omitempty" opt:"log-driver"`
|
|
|
|
LogOpts map[string]string `yaml:"log_opts,omitempty" opt:"log-opt"`
|
|
|
|
PidFile string `yaml:"pid_file,omitempty" opt:"pidfile"`
|
|
|
|
RegistryMirror string `yaml:"registry_mirror,omitempty" opt:"registry-mirror"`
|
|
|
|
Restart *bool `yaml:"restart,omitempty" opt:"restart"`
|
|
|
|
SelinuxEnabled *bool `yaml:"selinux_enabled,omitempty" opt:"selinux-enabled"`
|
|
|
|
StorageDriver string `yaml:"storage_driver,omitempty" opt:"storage-driver"`
|
|
|
|
UserlandProxy *bool `yaml:"userland_proxy,omitempty" opt:"userland-proxy"`
|
2016-09-26 00:55:19 +00:00
|
|
|
}
|
|
|
|
|
2015-03-18 13:23:27 +00:00
|
|
|
type DockerConfig struct {
|
2016-09-26 00:55:19 +00:00
|
|
|
EngineOpts
|
2016-08-15 22:06:26 +00:00
|
|
|
Engine string `yaml:"engine,omitempty"`
|
2015-08-27 19:24:26 +00:00
|
|
|
TLS bool `yaml:"tls,omitempty"`
|
|
|
|
TLSArgs []string `yaml:"tls_args,flow,omitempty"`
|
|
|
|
ExtraArgs []string `yaml:"extra_args,flow,omitempty"`
|
|
|
|
ServerCert string `yaml:"server_cert,omitempty"`
|
|
|
|
ServerKey string `yaml:"server_key,omitempty"`
|
|
|
|
CACert string `yaml:"ca_cert,omitempty"`
|
|
|
|
CAKey string `yaml:"ca_key,omitempty"`
|
|
|
|
Environment []string `yaml:"environment,omitempty"`
|
|
|
|
StorageContext string `yaml:"storage_context,omitempty"`
|
2015-12-22 22:14:51 +00:00
|
|
|
Exec bool `yaml:"exec,omitempty"`
|
2015-03-15 04:27:04 +00:00
|
|
|
}
|
|
|
|
|
2016-11-28 08:06:00 +00:00
|
|
|
type SSHConfig struct {
|
2018-03-05 06:49:52 +00:00
|
|
|
Keys map[string]string `yaml:"keys,omitempty"`
|
|
|
|
Daemon bool `yaml:"daemon,omitempty"`
|
|
|
|
Port int `yaml:"port,omitempty"`
|
|
|
|
ListenAddress string `yaml:"listen_address,omitempty"`
|
2016-01-28 15:27:17 +00:00
|
|
|
}
|
|
|
|
|
2015-03-18 13:23:27 +00:00
|
|
|
type StateConfig struct {
|
2015-12-20 05:34:07 +00:00
|
|
|
Directory string `yaml:"directory,omitempty"`
|
2015-03-18 13:23:27 +00:00
|
|
|
FsType string `yaml:"fstype,omitempty"`
|
|
|
|
Dev string `yaml:"dev,omitempty"`
|
2016-07-28 06:25:08 +00:00
|
|
|
Wait bool `yaml:"wait,omitempty"`
|
2015-03-18 13:23:27 +00:00
|
|
|
Required bool `yaml:"required,omitempty"`
|
|
|
|
Autoformat []string `yaml:"autoformat,omitempty"`
|
2015-12-21 06:26:34 +00:00
|
|
|
MdadmScan bool `yaml:"mdadm_scan,omitempty"`
|
2018-10-31 13:36:59 +00:00
|
|
|
LvmScan bool `yaml:"lvm_scan,omitempty"`
|
|
|
|
Cryptsetup bool `yaml:"cryptsetup,omitempty"`
|
2018-09-14 08:34:09 +00:00
|
|
|
Rngd bool `yaml:"rngd,omitempty"`
|
2015-12-21 06:26:34 +00:00
|
|
|
Script string `yaml:"script,omitempty"`
|
2015-12-20 05:26:09 +00:00
|
|
|
OemFsType string `yaml:"oem_fstype,omitempty"`
|
|
|
|
OemDev string `yaml:"oem_dev,omitempty"`
|
2018-09-30 06:30:25 +00:00
|
|
|
BootFsType string `yaml:"boot_fstype,omitempty"`
|
|
|
|
BootDev string `yaml:"boot_dev,omitempty"`
|
2015-03-15 04:27:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type CloudInit struct {
|
|
|
|
Datasources []string `yaml:"datasources,omitempty"`
|
|
|
|
}
|
2015-03-20 18:35:21 +00:00
|
|
|
|
2016-05-03 15:55:15 +00:00
|
|
|
type Defaults struct {
|
2018-10-10 08:37:17 +00:00
|
|
|
Hostname string `yaml:"hostname,omitempty"`
|
|
|
|
Docker DockerConfig `yaml:"docker,omitempty"`
|
|
|
|
Network netconf.NetworkConfig `yaml:"network,omitempty"`
|
|
|
|
SystemDockerLogs string `yaml:"system_docker_logs,omitempty"`
|
2016-05-03 15:55:15 +00:00
|
|
|
}
|
|
|
|
|
2015-09-23 11:36:28 +00:00
|
|
|
func (r Repositories) ToArray() []string {
|
|
|
|
result := make([]string, 0, len(r))
|
|
|
|
for _, repo := range r {
|
2016-11-28 08:06:00 +00:00
|
|
|
if repo.URL != "" {
|
|
|
|
result = append(result, repo.URL)
|
2015-09-23 11:36:28 +00:00
|
|
|
}
|
2015-03-20 18:35:21 +00:00
|
|
|
}
|
2015-09-23 11:36:28 +00:00
|
|
|
|
|
|
|
return result
|
2015-03-20 18:35:21 +00:00
|
|
|
}
|