Merge pull request #6498 from neumayer/ocimetadata
Allow instance metadata to be specified in config
This commit is contained in:
commit
67f039509a
@ -48,6 +48,13 @@ type Config struct {
|
||||
// Instance
|
||||
InstanceName string `mapstructure:"instance_name"`
|
||||
|
||||
// Metadata optionally contains custom metadata key/value pairs provided in the
|
||||
// configuration. While this can be used to set metadata["user_data"] the explicit
|
||||
// "user_data" and "user_data_file" values will have precedence.
|
||||
// An instance's metadata can be obtained from at http://169.254.169.254 on the
|
||||
// launched instance.
|
||||
Metadata map[string]string `mapstructure:"metadata"`
|
||||
|
||||
// UserData and UserDataFile file are both optional and mutually exclusive.
|
||||
UserData string `mapstructure:"user_data"`
|
||||
UserDataFile string `mapstructure:"user_data_file"`
|
||||
|
@ -29,6 +29,9 @@ func testConfig(accessConfFile *os.File) map[string]interface{} {
|
||||
// Comm
|
||||
"ssh_username": "opc",
|
||||
"use_private_ip": false,
|
||||
"metadata": map[string]string{
|
||||
"key": "value",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,11 @@ func (d *driverOCI) CreateInstance(ctx context.Context, publicKey string) (strin
|
||||
metadata := map[string]string{
|
||||
"ssh_authorized_keys": publicKey,
|
||||
}
|
||||
if d.cfg.Metadata != nil {
|
||||
for key, value := range d.cfg.Metadata {
|
||||
metadata[key] = value
|
||||
}
|
||||
}
|
||||
if d.cfg.UserData != "" {
|
||||
metadata["user_data"] = d.cfg.UserData
|
||||
}
|
||||
|
@ -125,6 +125,10 @@ builder.
|
||||
|
||||
- `use_private_ip` (boolean) - Use private ip addresses to connect to the instance via ssh.
|
||||
|
||||
- `metadata` (map of strings) - Metadata optionally contains custom metadata key/value pairs provided in the
|
||||
configuration. While this can be used to set metadata["user_data"] the explicit "user_data" and "user_data_file" values will have precedence. An instance's metadata can be obtained from at http://169.254.169.254 on the
|
||||
launched instance.
|
||||
|
||||
- `user_data` (string) - user_data to be used by cloud
|
||||
init. See [the Oracle docs](https://docs.us-phoenix-1.oraclecloud.com/api/#/en/iaas/20160918/LaunchInstanceDetails) for more details. Generally speaking, it is easier to use the `user_data_file`,
|
||||
but you can use this option to put either the plaintext data or the base64
|
||||
|
Loading…
x
Reference in New Issue
Block a user