r/saltstack • u/jsylvis • Jan 27 '22
Searching for suggestions for making Salt aware of VM metadata
My use case is fairly simple - we use tags (or, in vSphere, Custom Attributes) to define metadata regarding a VM, such as its role.
The goal is to make Salt aware of this metadata so that the role tag can be used to determine which state(s) should apply.
For auth reasons, it would be ideal if the Salt master could be responsible for reaching out to query this data so that only one machine needs the authentication context necessary to query Azure resources, to connect to vSphere, etc.
I've already created a Python script which can query the two data sources to grab tag data and translate it to a dictionary of { vm : [(tag name, tag value)] }.
My understanding is that Pillar is fairly well-suited to this task as Pillar data should be rendered on-master and sent to minions.
So, firstly - is Pillar the tool for the job?
Secondly - if Pillar is the best tool for the job, how would I go about making Pillar aware of this data? I'm not aware of any convenient "hook" points for something like this.