salt-formulas / reclass

A recursive external node classifier for automation tools like Ansible, Puppet, and Salt
Other
53 stars 23 forks source link

Fix identical inventory queries with different flags returning incorrect data #94

Closed AndrewPickford closed 4 years ago

AndrewPickford commented 4 years ago

With two identical inventory queries, one with the AllEnvs flag and one without both queries return the data from the query with the AllEnvs flag set.

Inventory queries use a pre calculated list of nodes to loop over to determine which nodes match the inventory query. If any inventory queries have the AllEnvs flag set then nodes from all environments will be present in the pre calculated list of nodes. Thus other queries which do not have the AllEnvs flags set could then match nodes from other environments.

The fix adds a test to the invitem class when assembling the inventory query result to check that the node environments match or that the query has the AllEnvs flag set. Unit tests are also added to check this functionality.