Here’s some notes I took during the excellent Getting Started with Ansible on Windows course on Pluralsight, specific to Azure VMs. I was trying to set up a cluster of servers to use as Azure Devops build agents, so my notes all relate to that.
- Create some Azure VMs using a script like this one
- Add networking rules to each to allow WinRM over HTTPS: inbound TCP port 5986 (my example script above already does this)
- Also run the ConfigureRemotingForAnsible script (my example script does this too)
- Ansible’s win_ping module doesn’t actually use ICMP ping so if you have issues with it, they aren’t related to a firewall blocking pings.
- In ansible’s hosts file, you don’t need to put the domain on the username like is demonstrated in the course, I tried vmname\username, username@vmname and so on, none worked. Obviously in a real domain it wouldn’t work like that anyway.
I ended up with this Ansible hosts file:
And here’s the playbook I used to set up my demo build servers. It registers the Azure pipelines agent first, then installs a bunch of different frameworks and build tools that we’ve used for some projects. Probably don’t authenticate your agents with your personal access token, though.
Unrelated to Ansible, but I spent more time on this than anything else: For some reason Azure Devops’ Nuget tool installer always ended up either installing 4.3 or 4.4, so if you get errors like the below, make sure it’s using the right version (as of this writing, that was 4.x = 4.9.4).
##[error]The nuget command failed with exit code(1) and error(Error parsing solution file at C:\agent\_work\1\s\src\SolutionName.sln: Exception has been thrown by the target of an invocation. The project file could not be loaded. Could not load file or assembly 'Microsoft.Build.Framework, Version=188.8.131.52, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.