Ansible setup with Azure on a new Mac
Following on from upgrading my Macs to all M1-based ones, I get around to finally needing to use Ansible; typically, I would install Python using PyEnv and then run the following …
pip install --user ansiblepip install --user -r https://github.com/ansible-collections/azure/blob/dev/requirements-azure.txtansible-galaxy collection install azure.azcollection… and away we go, but this time I came across a few problems.
The first was the following error when installing the requirements using the remote requirements-azure.txt file:
This was an easy one to fix; I just needed to run the following to get enough of the pre-requisites installed …
brew install openssl@1.1 rustOnce installed, I then needed to update the pip command I was using, so it looks like this:
env LDFLAGS="-L$(brew --prefix openssl@1.1)/lib" CFLAGS="-I$(brew --prefix openssl@1.1)/include" pip install --user -r https://github.com/ansible-collections/azure/blob/dev/requirements-azure.txtHey presto, cryptography built and installed OK. However, things changed when running Ansible; I got the following error …
Erm, how could that be? Everything was installed as expected with no errors after installing the correct version of OpenSSL and Rust. It turns out that my usual way of installing Ansible isn’t actually the recommended way, so let’s look at how I should have installed it using the following commands …
brew install openssl@1.1 rustenv LDFLAGS="-L$(brew --prefix openssl@1.1)/lib" CFLAGS="-I$(brew --prefix openssl@1.1)/include" pip install --user cryptographypip install --user ansibleansible-galaxy collection install azure.azcollectionpip install --user -r ~/.ansible/collections/ansible_collections/azure/azcollection/requirements-azure.txtAs you can see, first of all by installing the cryptography module and its pre-requisites, then install Ansible and then the Azure collection. Once the Azure collection is installed, use the requirements-azure.txt which ships with the collection rather than remotely using the one straight from GitHub - this is because the one in GitHub is way ahead of the one which is the current release of the Azure collection on Ansible Galaxy.
While things “may work” if there is active development going on which has not made its way into the Ansible Galaxy release, then you may have all sorts of compatibility issues, just like I did.
Hopefully, this saves someone scratching their head for hours as I did as everything looked to have been correct, and the azure.mgmt.monitor module was 100% installed, just not the version which the collection was expecting.
Share
Related Posts

How to Install Ansible on a Mac: A Modern Approach
A guide to installing and managing Ansible on macOS using Conda, with tips for handling collections and dependencies.

Azure DevOps Ansible Pipeline; Boosting Efficiency with Caching
Discover how to optimize your Azure DevOps Ansible pipeline with caching techniques. Learn to reduce execution time, improve efficiency, and maintain security checks in your infrastructure as code deployments.

Personal Project Updates and AI Editors
About that time I wrote and published an App to the Apple App Store without knowing how to code
