Skip to content

How to Use This Repo

James Cuzella edited this page May 22, 2022 · 8 revisions

Usage

The files contained in this repository will not work on their own. Unfortunately due to Apple's EULA, we can't distribute the actual Vagrant .box file that this repository's code references. You will have to build your own QEMU image for use with the open source libvirt & qemu tools.

Thanks to the OSX-KVM project, this has become much easier.

The steps to create an image for use with KVM, libvirt and QEMU are documented at the following link:

Once you have a working QCOW2 .img file, and libvirt VM (.xml definition for use with virsh), you are ready to create a Vagrant Box as usual.

There is a helper script, package.sh in this repo which helps to run the same packaging command used to create the private LyraPhase-runner box. To use this:

  1. Optional: Edit the Vagrantfile and change any settings you may wish.
  • This Vagrantfile will be packaged as default settings for distribution inside the .box file.
  • For example, you may wish to:
    • Change the box name: config.vm.box
    • Change the hostname: config.vm.hostname
    • Change the NVRAM file path or name: libvirt.nvram
    • Assign more RAM: libvirt.memory
    • Change number of CPUs: CPU_SOCKETS, CPU_CORES, CPU_THREADS (Hint: Stick to a supported well-known CPU topology for your Host)
  • It's not recommended to stray too far away from the default hardware configuration, unless you are experienced at using libvirt VM definitions for macOS
  1. Edit info.json:
  • Replace author with your Vagrant Cloud or CI/CD username
  1. Run package.sh and pass it your .box output filename:

    ./package.sh exampleuser-monterey-12-1-base.box
    
  2. Use for any testing, CI/CD projects that need a MacOS VM!

  • Plain Vagrant Box:
    • Place a Vagrantfile that references your .box URL and/or name in your project's directory
    • Run vagrant up as usual
  • Test Kitchen:
    • Install vagrant-libvirt dependencies

    • Install vagrant-libvirt Vagrant plugin:

      vagrant plugin install vagrant-libvirt
      
    • Place a .kitchen.libvirt.yml in your cookbook's directory

    • Under driver settings, set: driver: vagrant, & provider: libvirt

      driver:
        name: vagrant
        provider: libvirt
      
    • Reference the .box URL and/or name for any per-host MacOS platforms under test:

      platforms:
        - name: macos-12.1
          lifecycle:
            pre_converge:
            - remote: sudo mkdir -p /tmp/kitchen
            - remote: sudo chown -R vagrant:vagrant /tmp/kitchen
          driver:
            box: exampleuser/monterey-12-1-base
            box_url: http://example-privatehost.local:8888/exampleuser-monterey-12-1-base.box
            communicator: ssh
            gui: true
            customize:
              memory: 4096
      
Clone this wiki locally