I’ve decided to use Ansible to set up a virtual VM with MacOS. I used to have a mac or two, but my hardware is obsolete now (Intel core 2 duo, anyone?) and I can’t justify paying a couple of thousand Euros every few years for what practically amounts to renting machines.
I’ve got a while ago a cheapo server, shoved in some memory and found a blog entry outlining steps to install MacOS on ESXi. Cool!
- First step is to patch ESXi, because you can’t just install MacOS out of the box.
- Then, I prepared the VM. It took me few tries, but I got the following configuration ready:
- min 16GB of RAM
- min 2 vCPUs (I allocated 4)
- min 250GB of disk space. SSD is essential for the machine!
- Install MacOS (Mojave at the time of writing)
- Create an apple id account (if you don’t have it)
- Update to most recent version
- Install XCode
- Accept license agreement
- Install tools etc.
Now, the bare VM is ready. The next step is to set up all the tools one might need for e.g. development. This will be done via Ansible.
First step after the OS is installed is to set up password-less login from the master. From the master node, run:
cd ~/.ssh cat ./id_rsa.pub | ssh [email protected] 'cat >> .ssh/authorized_keys'
As quite a lot of commands need root (not administrator), we need to enable it on the machine (at least until we finish the Ansible setup). Use this link to enable root on the MacOS VM.
On the master node, you can set up a secret file with the encoded password. This SO question offers several pros and cons for different solutions
To enable elevation, you will then be able to execute a playbook like this:
ansible-playbook mac.yaml --extra-vars "ansible_become_pass=<password>"
Next chapter will detail the Ansible setup.