Skip to content
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

add the before_start_hook #251

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

rgl
Copy link
Contributor

@rgl rgl commented Feb 1, 2024

this is a PoC for #198.

I'm looking for suggestions about the name of the configuration property, currently, its called before_start_hook.

if you agree with this change, I'll later will be adding the missing documentation.

the before_start_hook configuration setting contains the command that will be executed after the vm is configured, but before its started.

the command receives the current vm configuration as a json in its stdin

the hook command is expected to return a json with the modified configuration, typically, this document should only contain the properties that you want to actually modify.

the following example is modifying the ide0 and ide1 media from cdrom to disk, something that is useful when we have a disk image instead of an iso:

source "proxmox-iso" "macos-amd64" {
  # ...
  before_start_hook = [
    "python3",
    "-c",
    <<-EOF
    import json, sys
    config = json.load(sys.stdin)
    print(json.dumps({
      "ide0": config["ide0"].replace("media=cdrom", "media=disk"),
      "ide2": config["ide2"].replace("media=cdrom", "media=disk"),
    }))
    EOF
  ]

Closes #198

this will executed after the vm is configured, but before its started

this receives the vm configuration as a json in stdin

the hook is expected to return a json with the modified configuration
@rhpijnacker-philips
Copy link

It seems to me this is a bit of a kludge.
It means that we are not currently able to express the desired configuration with the existing parameters.

@rgl
Copy link
Contributor Author

rgl commented Feb 12, 2024

@rhpijnacker-philips yes, like described at #198, this is an escape hatch, to use in those cases where there is no other way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Give us enough rope to edit the raw VM creation request
2 participants