dmacvicar / terraform-provider-libvirt

Terraform provider to provision infrastructure with Linux's KVM using libvirt
Apache License 2.0
1.54k stars 457 forks source link

It's possible to use at Macos with Apple silicon processor? #1016

Closed mgnkir closed 5 months ago

mgnkir commented 1 year ago

System Information

MacBook Pro 16" M1 Pro

Linux distribution

Macos 13.2.1

Terraform version

Terraform v1.4.5
on darwin_arm64
+ provider registry.terraform.io/dmacvicar/libvirt v0.7.1

Provider and libvirt versions

.terraform/providers/registry.terraform.io/dmacvicar/libvirt/0.7.1/darwin_arm64/terraform-provider-libvirt_v0.7.1 0.7.1

If that gives you "was not built correctly", get the Git commit hash from your local provider repository:


Checklist

Description of Issue/Question

Setup

terraform {
  required_providers {
    libvirt = {
      source = "dmacvicar/libvirt"
    }
  }
}

provider "libvirt" {
  uri = "qemu:///session?socket=/Users/USERNAME/.cache/libvirt/libvirt-sock"
}

resource "libvirt_domain" "test" {
  name   = "test"
}

Steps to Reproduce Issue

kirillkuchma@Kirills-MacBook-Pro libvirt % terraform apply 

Terraform used the selected providers to generate the following execution plan.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # libvirt_domain.test will be created
  + resource "libvirt_domain" "test" {
      + arch        = (known after apply)
      + autostart   = (known after apply)
      + emulator    = (known after apply)
      + fw_cfg_name = "opt/com.coreos/config"
      + id          = (known after apply)
      + machine     = (known after apply)
      + memory      = 512
      + name        = "test"
      + qemu_agent  = false
      + running     = true
      + vcpu        = 1
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

libvirt_domain.test: Creating...
╷
│ Error: [DEBUG] Could not find any guests for architecure type hvm/aarch64
│ 
│   with libvirt_domain.test,
│   on main.tf line 15, in resource "libvirt_domain" "test":
│   15: resource "libvirt_domain" "test" {
│ 
╵

Magnitus- commented 1 year ago

If you want to operate on a Linux machine via ssh from your M1 macos machine, maybe? (although last I checked, you needed to have a xsltproc binary setup in your path, not sure the status of that on macs).

If you are hoping to run kvm workloads directly on your machine... best of luck (as kvm is part of Linux).

I won't claim it is impossible (just highly improbable) as I'm not knowledgeable enough about the Mac ecosystem to make that claim. We have a colleague who was in your exact situation and he had to wait for a Linux machine before he could start working on our kvm tooling locally. He didn't manage to hack a solution around it. I haven't tried (I don't have a Mac and I'll be frank, my interest is low).

My personal advice: Either get a Linux machine or stick with containers in a Linux vm.

fsdrw08 commented 5 months ago

any update for this issue? I just wonder if possible to use this provider to create vm in macOS with apple silicon base machine.

michaelbeaumont commented 5 months ago

This question isn't really specific to this terraform provider. First, figure out how to do this using libvirt, if it's possible. You'll need to determine the correct domain type and architecture. Then use those parameters with the libvirt_domain resource.

If you can create a libvirt domain on said machine but can't do it using this provider, then definitely come back and let us know.