geerlingguy / mac-dev-playbook

Mac setup and configuration via Ansible.
Other
6.01k stars 1.77k forks source link

Document running playbook against local macOS VM for testing #160

Open geerlingguy opened 2 years ago

geerlingguy commented 2 years ago

I recently had some time to play around with virtualization options on M1, and thought I'd document some tests I'm doing with this playbook against different macOS instances running inside VMs.

For now, I'm looking at Tart and UTM.

geerlingguy commented 2 years ago

Tart installation is simple:

brew install cirruslabs/cli/tart
tart clone ghcr.io/cirruslabs/macos-monterey-base:latest monterey-base
tart run monterey-base

A VM is brought up with the default login admin/admin, with Remote Login on, and an IP address (at least in my case) of 192.168.64.2. It looks like the VM framework sets up a bridge100 network on the host (found using ifconfig).

Screen Shot 2022-07-29 at 11 43 51 AM

I can ssh into the VM with ssh admin@192.168.64.2.

To run mac-dev-playbook against the VM from my Mac, I cloned this project, then changed the inventory file:

[all]
192.168.64.2  ansible_user=admin

Then I ran the playbook:

ansible-playbook main.yml --ask-pass

(To use a password instead of an SSH key I installed brew install hudochenkov/sshpass/sshpass.)

Everything worked great!

Screen Shot 2022-07-29 at 11 50 17 AM

Now I'm considering whether it would be simpler to set up a VM in CI too, so the test rig would be identical between GitHub Actions and local!

archae0pteryx commented 2 years ago

@geerlingguy this is great! Doing a quick scan here i didn't see any obvious hits, but i wonder if you've ever laid out how to do this on an intel chip. I've done a bit of googling but finding the os x images is a pain. I wish there were something like tart that just "handled" it. Do you have some resources you might share that would cut down on the google guff?

geerlingguy commented 2 years ago

@archae0pteryx - I used to use https://github.com/geerlingguy/macos-virtualbox-vm but it was getting a bit complicated to try to set up a VM on Intel macOS :(