What I'd like to do is generate multiple configuration files for each openvpn user. I have the IP address and additional configuration in pillar.
For example:
openvpn:
- user1:
ip: 1.2.3.4
config:
- line1
- line2
In the SLS I'd like to do something like:
{% for vpnuser in salt['pillar.get']('openvpn') %}
/etc/openvpn/ccd/{{ vpnuser }}:
file.managed:
- template: jinja
- source: salt://openvpn/ccdtemplate
{% endfor %}
and in the ccdtemplate I'd like to generate the config depending on the user and the config data for this user stored in pillar.
But therefor I would need to know the content of the variable 'vpnuser' from the state.
Is it possible to pass variables from a state to the jinja template?
You can pass any value you need to the template by using the
defaults
keyword. In your case, this would be:This is documented in http://docs.saltstack.com/en/latest/ref/states/all/salt.states.file.html