Skip to content

Commit

Permalink
Add common extra specs
Browse files Browse the repository at this point in the history
  • Loading branch information
fabi200123 committed Jun 10, 2024
1 parent 4e0aa42 commit 1a2ef13
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 6 deletions.
59 changes: 58 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,36 @@ To this end, this provider supports the following extra specs schema:
"hardware_reservation_id": {
"type": "string",
"description": "The hardware reservation ID to use."
},
"disable_updates": {
"type": "boolean",
"description": "Disable automatic updates on the VM."
},
"enable_boot_debug": {
"type": "boolean",
"description": "Enable boot debug on the VM."
},
"extra_packages": {
"type": "array",
"description": "Extra packages to install on the VM.",
"items": {
"type": "string"
}
},
"runner_install_template": {
"type": "string",
"description": "This option can be used to override the default runner install template. If used, the caller is responsible for the correctness of the template as well as the suitability of the template for the target OS. Use the extra_context extra spec if your template has variables in it that need to be expanded."
},
"extra_context": {
"type": "object",
"description": "Extra context that will be passed to the runner_install_template.",
"additionalProperties": {
"type": "string"
}
},
"pre_install_scripts": {
"type": "object",
"description": "A map of pre-install scripts that will be run before the runner install script. These will run as root and can be used to prep a generic image before we attempt to install the runner. The key of the map is the name of the script as it will be written to disk. The value is a byte array with the contents of the script."
}
},
"additionalProperties": false
Expand All @@ -90,10 +120,37 @@ An example extra specs json would look like this:
```json
{
"metro_code": "AM",
"hardware_reservation_id": "UUID_GOES_HERE"
"hardware_reservation_id": "UUID_GOES_HERE",
"disable_updates": true,
"enable_boot_debug": true,
"extra_context": {
"GolangDownloadURL": "https://go.dev/dl/go1.22.4.linux-amd64.tar.gz"
},
"extra_packages": [
"apg",
"tmux"
],
"pre_install_scripts": {
"01-script": "IyEvYmluL2Jhc2gKCgplY2hvICJIZWxsbyBmcm9tICQwIiA+PiAvMDEtc2NyaXB0LnR4dAo=",
"02-script": "IyEvYmluL2Jhc2gKCgplY2hvICJIZWxsbyBmcm9tICQwIiA+PiAvMDItc2NyaXB0LnR4dAo="
},
"runner_install_template": "Iy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ZCB0byBzdGFydCBzZXJ2aWNlIgp7ey0gZWxzZX19CnNlbmRTdGF0dXMgInN0YXJ0aW5nIHNlcnZpY2UiCnN1ZG8gLi9zdmMuc2ggc3RhcnQgfHwgZmFpbCAiZmFpbGVkIHRvIHN0YXJ0IHNlcnZpY2UiCgpzZXQgK2UKQUdFTlRfSUQ9JChncmVwICJhZ2VudElkIiAvaG9tZS97eyAuUnVubmVyVXNlcm5hbWUgfX0vYWN0aW9ucy1ydW5uZXIvLnJ1bm5lciB8ICB0ciAtZCAtYyAwLTkpCmlmIFsgJD8gLW5lIDAgXTt0aGVuCglmYWlsICJmYWlsZWQgdG8gZ2V0IGFnZW50IElEIgpmaQpzZXQgLWUKe3stIGVuZH19CnN5c3RlbUluZm8gJEFHRU5UX0lECgpzdWNjZXNzICJydW5uZXIgc3VjY2Vzc2Z1bGx5IGluc3RhbGxlZCIgJEFHRU5UX0lECnt7LSBpZiAuRXh0cmFDb250ZXh0LkdvbGFuZ0Rvd25sb2FkVVJMIH19CmN1cmwgLUxPIHt7IC5FeHRyYUNvbnRleHQuR29sYW5nRG93bmxvYWRVUkwgfX0Kcm0gLXJmIC91c3IvbG9jYWwvZ28gJiYgc3VkbyB0YXIgLUMgL3Vzci9sb2NhbCAteHpmIGdvMS4yMi40LmxpbnV4LWFtZDY0LnRhci5negpleHBvcnQgUEFUSD0kUEFUSDovdXNyL2xvY2FsL2dvL2Jpbgp7ey0gZW5kIH19"
}
```

*NOTE*: The `extra_context` spec adds a map of key/value pairs that may be expected in the `runner_install_template`.
The `runner_install_template` allows us to completely override the script that installs and starts the runner. In the example above, I have added a copy of the current template from `garm-provider-common`, with the adition of:

```bash
{{- if .ExtraContext.GolangDownloadURL }}
curl -LO {{ .ExtraContext.GolangDownloadURL }}
rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.22.4.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
{{- end }}
```
*NOTE*: `runner_install_template` is a [golang template](https://pkg.go.dev/text/template), which is used to install the runner. An example on how you can extend the currently existing template with a function that downloads, extracts and installs Go on the runner is provided above.
To set it on an existing pool, simply run:
```bash
Expand Down
59 changes: 54 additions & 5 deletions internal/spec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,36 @@ const jsonSchema string = `
"hardware_reservation_id": {
"type": "string",
"description": "The hardware reservation ID to use."
},
"disable_updates": {
"type": "boolean",
"description": "Disable automatic updates on the VM."
},
"enable_boot_debug": {
"type": "boolean",
"description": "Enable boot debug on the VM."
},
"extra_packages": {
"type": "array",
"description": "Extra packages to install on the VM.",
"items": {
"type": "string"
}
},
"runner_install_template": {
"type": "string",
"description": "This option can be used to override the default runner install template. If used, the caller is responsible for the correctness of the template as well as the suitability of the template for the target OS. Use the extra_context extra spec if your template has variables in it that need to be expanded."
},
"extra_context": {
"type": "object",
"description": "Extra context that will be passed to the runner_install_template.",
"additionalProperties": {
"type": "string"
}
},
"pre_install_scripts": {
"type": "object",
"description": "A map of pre-install scripts that will be run before the runner install script. These will run as root and can be used to prep a generic image before we attempt to install the runner. The key of the map is the name of the script as it will be written to disk. The value is a byte array with the contents of the script."
}
},
"additionalProperties": false
Expand Down Expand Up @@ -91,7 +121,10 @@ type extraSpecs struct {
// See: https://deploy.equinix.com/developers/docs/metal/locations/metros/
MetroCode string `json:"metro_code"`
// HardwareReservationID is the UUID representing the hardware reservation to use.
HardwareReservationID *string `json:"hardware_reservation_id,omitempty"`
HardwareReservationID *string `json:"hardware_reservation_id,omitempty"`
DisableUpdates *bool `json:"disable_updates"`
EnableBootDebug *bool `json:"enable_boot_debug"`
ExtraPackages []string `json:"extra_packages"`
}

func GetRunnerSpecFromBootstrapParams(data params.BootstrapInstance, controllerID string) (*RunnerSpec, error) {
Expand All @@ -113,6 +146,7 @@ func GetRunnerSpecFromBootstrapParams(data params.BootstrapInstance, controllerI
}

spec := &RunnerSpec{
ExtraPackages: extraSpecs.ExtraPackages,
BootstrapParams: data,
Tools: tools,
Tags: tags,
Expand All @@ -130,6 +164,9 @@ type RunnerSpec struct {
ProjectID string
MetroCode string
HardwareReservationID *string
DisableUpdates bool
ExtraPackages []string
EnableBootDebug bool
Tools params.RunnerApplicationDownload
Tags []string
BootstrapParams params.BootstrapInstance
Expand All @@ -155,20 +192,32 @@ func (r *RunnerSpec) MergeExtraSpecs(spec extraSpecs) {
if spec.MetroCode != "" {
r.MetroCode = spec.MetroCode
}

if spec.DisableUpdates != nil {
r.DisableUpdates = *spec.DisableUpdates
}

if spec.EnableBootDebug != nil {
r.EnableBootDebug = *spec.EnableBootDebug
}
}

func (r *RunnerSpec) ComposeUserData() (string, error) {
switch r.BootstrapParams.OSType {
bootstrapParams := r.BootstrapParams
bootstrapParams.UserDataOptions.DisableUpdatesOnBoot = r.DisableUpdates
bootstrapParams.UserDataOptions.ExtraPackages = r.ExtraPackages
bootstrapParams.UserDataOptions.EnableBootDebug = r.EnableBootDebug
switch bootstrapParams.OSType {
case params.Linux, params.Windows:
default:
return "", fmt.Errorf("unsupported OS type for cloud config: %s", r.BootstrapParams.OSType)
return "", fmt.Errorf("unsupported OS type for cloud config: %s", bootstrapParams.OSType)
}

udata, err := DefaultGetCloudconfig(r.BootstrapParams, r.Tools, r.BootstrapParams.Name)
udata, err := DefaultGetCloudconfig(bootstrapParams, r.Tools, bootstrapParams.Name)
if err != nil {
return "", fmt.Errorf("failed to generate userdata: %w", err)
}
if r.BootstrapParams.OSType == params.Windows {
if bootstrapParams.OSType == params.Windows {
udata = fmt.Sprintf("#ps1_sysnative\n%s", udata)
}
return udata, nil
Expand Down

0 comments on commit 1a2ef13

Please sign in to comment.