ServiceNowITOM / ansible-sn-inventory

Ansible Dynamic Inventory for ServiceNow
Apache License 2.0
79 stars 45 forks source link

Pretty print cache for easier diffing #24

Closed ursetto closed 5 years ago

ursetto commented 5 years ago

This inserts newlines after each key/value pair in the generated __snow_inventory__ cache, making it possible to diff with an earlier version. This is useful when debugging script development, effects of config file changes, or just to have a record of your changing inventory over time---especially if the cache is committed to version control. On a 5MB file I measured about 150KB of newlines, or a 3% increase. It does not indent the result, as it's not useful for diffing and wastes too much space.

Keys under each host are also sorted to keep the output stable and diff-able. No sorting of hosts is done (by name or sys_id) because in practice the host order returned by ServiceNow is stable.