I’m trying to figure out how to emit a configuration file for jmxtrans. The config is json, the values I need to fill in are known by ansible, but I’m having a hell of a time building up the dict structure and dumping to json using the template module’s to_json filter.
The simple explanation is that I’d like to loop over a list of servers from an inventory group, copy a few dictionaries from a vars file thereby building up a completely new dict and then dump that to a json file that jmxtrans uses for configuration.
If I had a way to turn on extension, I could do all of this in jinja2:
https://gist.github.com/davidbirdsong/9355702
I keep needing to be able to turn on extensions and take that as an indicator that I’m doing it the wrong way. Perhaps I am? Is there a more ansible-native way to loop on data and create new structures at play-time?
Here’s my vars.yml file: https://gist.github.com/davidbirdsong/9355770