Refactoring AA Solution Onboarding to give Linux some love

Refactoring AA Solution Onboarding to give Linux some love

August 11, 2019 0 By Morten Lerudjordet

So some of us are using the free update management and change management solution offered through Azure Automation.

There have been some code in the AA team github repo for some time, though as with all code it degrades over time as dependencies change.

This logic seemed to support onboarding both Windows and Linux, and I did not question this the first time I refactored the code. Though as it turns out Windows and Linux does not follow the same pattern when it comes to what identificator it uses to onboard VMs. The key difference is that for Windows the Id used can be extracted from the ARM api. Namely the VMid property on a VM object. The original assumption was that this was the same for Linux. Though after some investigation it seems that what Linux VMs has for VMid is not the same. The value is instead the internal UUID found inside the OS. This means that to get this, one will need to extract it by interacting with the OS. This is more difficult than for Windows, as this is already taken care of by Azure during VM creation.

Also as we are doing the one stepp to the right routine I added versions both for AzureRM and Az module.

AzureRM Single VM Onboarding:
https://github.com/mortenlerudjordet/runbooks/blob/master/Utility/ARM/Enable-AutomationSolution.ps1
AzureRM Multi VM Onboarding:
https://github.com/mortenlerudjordet/runbooks/blob/master/Utility/ARM/Enable-MultipleSolution.ps1

Az Single VM Onboarding:
https://github.com/mortenlerudjordet/runbooks/blob/master/Utility/ARM/Enable-AutomationSolutionAz.ps1
Az Multi VM Onboarding:
https://github.com/mortenlerudjordet/runbooks/blob/master/Utility/ARM/Enable-MultipleSolutionAz.ps1

In addition there seems to be no maintenance of onboarded VM’s to the different solutions. Therefor I wrote a runbook that will compare the onboarded VM’s to the VM’s deployed in Azure. If VM’s have been removed from Azure, the Runbook will also remove them from the solutions.

AzureRM Solution query cleanup:
https://github.com/mortenlerudjordet/runbooks/blob/master/Utility/ARM/Format-AutomationSolutionSearch.ps1

Az Solution query cleanup:
https://github.com/mortenlerudjordet/runbooks/blob/master/Utility/ARM/Format-AutomationSolutionSearchAz.ps1

If you need to import the Az modules into AA take a look at:
https://github.com/mortenlerudjordet/runbooks/blob/master/Utility/ARM/Import-PSGalleryModulesToAA.ps1