Hybrid CI/CD Pipelines with Orka and Ansible

Managing hybrid CI/CD pipelines built on Orka with Ansible just got easier. Use our Ansible Dynamic Inventory plugin script to efficiently manage hybrid CI/CD pipelines built on Orka.

MacStadium is constantly developing new and improved open source tooling in order to better support the development communities that make use of our cloud-based, macOS compute resources. Most recently, we’ve developed an Ansible dynamic inventory plugin script to make it easier to manage hybrid CI/CD pipelines built on Orka, a unique enterprise-ready macOS virtualization platform that is built on Docker and Kubernetes and that exposes certain features of these tools to end users.

Orka supports a wide variety of CI pipeline architectures. For teams that are targeting a fully ephemeral system, we’ve developed a Jenkins plugin for Orka that dramatically reduces the technical overhead to get a first, working iteration stood up. Of course, we recognize that not all teams are targeting a fully ephemeral setup due to a variety of factors, such as nuanced build requirements and automation tooling preferences. To learn more about static, hybrid and ephemeral CI pipeline design for iOS and macOS, check out our eBook on the topic.

The Orka Ansible Dynamic Inventory works by querying Orka for metadata related to all macOS virtual machines (VMs) associated with the logged-in user. It then filters the resulting list of VM metadata to isolate running VMs, and potentially filters the list further, depending on user configuration. Finally, the plugin script converts that metadata into an inventory format that Ansible can parse. This is useful because it removes the need for DevOps teams to manually build inventory files that represent their Orka VMs when they wish to run Ansible commands against them en masse, such as you would do if you were provisioning build agents for a hybrid CI/CD pipeline.

Using the Orka Ansible Dynamic Inventory

To use the dynamic inventory plugin script for Orka, first you’ll need to install and login to the Orka CLI. Next, you’ll need to clone the repository down from MacStadium’s GitHub account to the machine that will act as your Ansible controller – it is generally considered a best practice for this machine to exist in the same network as your target machines for the sake of speed of execution of your Ansible playbook.

Once you have cloned the repository and signed into the Orka CLI, you’ll be ready to test the connection between your Ansible controller and your target VMs.

To do so, change directories into the base directory of the repo. Then run the following in order to print out your current inventory as JSON to the terminal:

python3 orka_inventory.py --list

Next, you’ll need to make the file executable, so that Ansible will be able to call it. To do so, run the following:

chmod +x orka_inventory.py

Then, you’ll need to set your Ansible SSH credentials as environment variables on the Ansible controller, like so:

export ANSIBLE_SSH_USER=
‍export ANSIBLE_SSH_PASS=

Finally, you’ll be ready to test the setup. Ansible’s ping module will come in handy here. To test, run the following:

sudo ansible all -i orka_inventory.py -m ping

And voila! Now you’ll be able to run any Ansible playbook you like against your Orka VMs without the manual, and error-prone process of collecting each of your VM’s connection details in an Ansible inventory file.

TL;DR

Orka is a highly scaleable, enterprise-ready, macOS virtualization platform that can accommodate a wide variety of iOS and macOS CI/CD architectures. Above, we looked at using one of MacStadium’s many open source tools – the Orka Ansible Dynamic Inventory – as a means of provisioning iOS and macOS build agents in hybrid clouds running in Orka.