Ansible Tower – How to use System Tracking

It took me a while to get my head around how to use the System Tracking feature in tower.  Mainly because of how I was coming at it based on my current usage with Windows environments running on a VCenter hypervisor.  If you can’t get your system tracking to work, then it’s probably because you made some of the same fundamental mistakes I did.

Hosts

My initial scripts were dealing with creating the VMs on vCenter so in order to do this I had to target localhost (the tower box) to get this done.  Unfortunately I kept this logic through to my scan results, running the Scan job against a specific VM supplying the hostname in a survey and gathering facts like the IP address from vSphere.  This meant that I didn’t get facts collected against the target hosts, but against tower which is not what I wanted.  I was not getting the system tracking option to compare machines doing it this way.

Best practice is to leave the Hosts section to all and let tower handle the connection via the inventories.  You will then get facts in the system tracking page instead of the message telling you set up a scan job against and inventory.

Custom Facts

You do really need to read the documentation carefully.  On windows, you gather facts with Powershell scripts, but you need to make sure that the output can be easily converted into a JSON object by tower.  It will handle this for you.

You can write your scripts any way you want, but as I’m from Linux world I like to pipe.  Here is an example of gathering DLL information.

$object = @{}
Get-ChildItem C:\Windows\System32\ -Filter *.dll -Recurse -ErrorAction ‘silentlycontinue’ | Select-Object -ExpandProperty VersionInfo -ErrorAction ‘silentlycontinue’ | Foreach-Object {
$object.($_.FileName) = $_.ProductVersion
}
echo $object

You still need to tell Ansible where to find these facts so use the fact_path argument.  But be aware that you may need to escape the path

– setup: fact_path=’C:\\ProgramData\\Ansible’

USABILITY

I’m going to round up with not so much an issue, but an observation.  I found that the more facts you gather, the longer the list will get.  On a very basic installation, collecting dlls, services, features, installed programs and a selection of config files the page was getting to be over 3000 lines long.  This makes it hard to navigate and find potential conflicts between systems.  The colour scheme does hint at where sections are divided, but they’re not obvious initially and can be easily missed.  To that end I had a quick play and put together a small google chrome extension to make section headers into clickable sections that could collapse the information tables.  I also added a summary of total conflicts per section.

ansible_tower_system_tracking_extension

The source code can be found on my github : https://github.com/aidygus/AnsibleTowerChromeExtension

And the extension is available from chrome https://chrome.google.com/webstore/detail/ansible-tower-sytem-track/klmeimccnodnkacekjnkgoiojakibhha

A very simple addition that makes all the difference.

Author: Aidan

An experienced Developer who transitioned into implementing Continuous Integration, Delivery and Improvement through the use of Agile and Lean, or to put it simply, The DevOps Specialist.

Leave a Reply

Your email address will not be published. Required fields are marked *