Background: I need to make an XML file like this:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="BaseOU" value="DC=myplace,DC=wan" />
<add key="OurOU" value="OU=Users,DC=myplace,DC=wan" />
<add key="EmailServer" value"email.server.com" />
<add key="EmailRecipient" value"monitor@email.com" />
</appSettings>
</configuration>
I would like to build this file dynamically so we can simply add new variables to pillar without having to change the jinja template for the managed file. Can I loop though pillar key/value pairs without knowing the keys?
For example, let's say my pillar.sls looks like this:
scriptvars:
BaseOU: DC=myplace,DC=wan
OurOU: OU=Users,DC=myplace,DC=wan
EmailServer: email.server.com
EmailRecipient: monitor@email.com
and I make a state that manages the file C:\script-config.xml, and the source is a jinja template similar to:
<?xml version="1.0"?>
<configuration>
<appSettings>
{% for unknownPillarKey in pillar.get['scriptvars'] %}
<add key="unknownPillarKey" value="{{ pillar['unknownPillarKey'] }}" />
{% endfor %}
</appSettings>
</configuration>
Question: How do I add a new entry to scriptvars in my pillar.sls and have the for loop in the jinja template pick it up (when I apply the state - this isn't a question about beacons/reactors) and add it to the managed file? I think the issue is my jinja for loop or syntax but I can't find any info online. Many thanks for any insight.