-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix consul stanza parsing when a configuration directory is used #5817
Changes from all commits
5a3a47c
006a9a1
e9fa8e5
4bfbeb6
d1ee78a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,15 @@ import ( | |
"github.com/hashicorp/nomad/nomad/structs/config" | ||
) | ||
|
||
// ParseConfigDefault returns the configuration base | ||
func ParseConfigDefault() *Config { | ||
return &Config{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are there more than just these three that need to have defaults set correctly? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are the only three where the defaults are required before decoding, other defaults are set in |
||
Consul: config.DefaultConsulConfig(), | ||
Autopilot: config.DefaultAutopilotConfig(), | ||
Vault: config.DefaultVaultConfig(), | ||
} | ||
} | ||
|
||
func ParseConfigFile(path string) (*Config, error) { | ||
// slurp | ||
var buf bytes.Buffer | ||
|
@@ -36,10 +45,10 @@ func ParseConfigFile(path string) (*Config, error) { | |
Client: &ClientConfig{ServerJoin: &ServerJoin{}}, | ||
ACL: &ACLConfig{}, | ||
Server: &ServerConfig{ServerJoin: &ServerJoin{}}, | ||
Consul: config.DefaultConsulConfig(), | ||
Autopilot: config.DefaultAutopilotConfig(), | ||
Consul: &config.ConsulConfig{}, | ||
Autopilot: &config.AutopilotConfig{}, | ||
Telemetry: &Telemetry{}, | ||
Vault: config.DefaultVaultConfig(), | ||
Vault: &config.VaultConfig{}, | ||
} | ||
|
||
err = hcl.Decode(c, buf.String()) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"acl": { | ||
"enabled": true | ||
}, | ||
"bind_addr": "0.0.0.0", | ||
"consul": { | ||
"ssl": true, | ||
"server_auto_join": false, | ||
"client_auto_join": false, | ||
"token": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" | ||
}, | ||
"data_dir": "/opt/data/nomad/data", | ||
"datacenter": "dc1", | ||
"enable_syslog": true, | ||
"leave_on_interrupt": true, | ||
"leave_on_terminate": true, | ||
"log_level": "INFO", | ||
"region": "global", | ||
"server": { | ||
"bootstrap_expect": 3, | ||
"enabled": true, | ||
"encrypt": "sHck3WL6cxuhuY7Mso9BHA==", | ||
"retry_join": [ | ||
"10.0.0.101", | ||
"10.0.0.102", | ||
"10.0.0.103" | ||
] | ||
}, | ||
"syslog_facility": "LOCAL0", | ||
"tls": { | ||
"ca_file": "/opt/data/nomad/certs/nomad-ca.pem", | ||
"cert_file": "/opt/data/nomad/certs/server.pem", | ||
"http": true, | ||
}, | ||
"vault": { | ||
"address": "http://host.example.com:8200", | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"acl": { | ||
"enabled": true | ||
}, | ||
"advertise": { | ||
"http": "host.example.com", | ||
"rpc": "host.example.com", | ||
"serf": "host.example.com" | ||
}, | ||
"bind_addr": "0.0.0.0", | ||
"data_dir": "/opt/data/nomad/data", | ||
"datacenter": "dc1", | ||
"enable_syslog": true, | ||
"leave_on_interrupt": true, | ||
"leave_on_terminate": true, | ||
"log_level": "INFO", | ||
"region": "global", | ||
"server": { | ||
"bootstrap_expect": 3, | ||
"enabled": true, | ||
}, | ||
"syslog_facility": "LOCAL0", | ||
"telemetry": { | ||
"collection_interval": "60s", | ||
"disable_hostname": true, | ||
"prometheus_metrics": true, | ||
"publish_allocation_metrics": true, | ||
"publish_node_metrics": true | ||
}, | ||
"tls": { | ||
"key_file": "/opt/data/nomad/certs/server-key.pem", | ||
"rpc": true, | ||
"verify_server_hostname": true | ||
}, | ||
"vault": { | ||
"create_from_role": "nomad-cluster", | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"advertise" = { | ||
"http" = "host.example.com" | ||
"rpc" = "host.example.com" | ||
"serf" = "host.example.com" | ||
} | ||
|
||
"autopilot" = { | ||
"cleanup_dead_servers" = true | ||
} | ||
|
||
"consul" = { | ||
"client_auto_join" = false | ||
"server_auto_join" = false | ||
"token" = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" | ||
} | ||
|
||
vault = { | ||
enabled = true | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: I would consider moving this logic into
LoadConfigDir
.