openvpn.tmpl 945 B

123456789101112131415161718192021222324
  1. {#-
  2. # OpenVPN VPNs (if any)
  3. #}
  4. {%- set networks = [] %}
  5. {%- for netname, network in salt['pillar.get']('ovpn', {}).items () if grains['id'] in network %}
  6. {%- do networks.append (netname) %}
  7. {%- endfor %}
  8. {%- for netname in networks|sort %}
  9. {%- set network = salt['pillar.get']('ovpn:' ~ netname) %}
  10. {%- set network_config = network.get ('config') %}
  11. {%- set host_stanza = network.get (grains['id']) %}
  12. {%- set host_config = host_stanza.get ('config', {}) %}
  13. #
  14. # {{ network_config.get ('_desc') }}
  15. {%- set interface = host_config.get ('interface', network_config.get ('interface')) %}
  16. {%- if network_config.get ('dev-type', 'tap') == 'tap' %}
  17. iface {{ interface }}
  18. {%- for ip in host_stanza.get ('ip', []) %}
  19. {%- set netmask = network_config['netmask_v6'] if ':' in ip else network_config['netmask_v4'] %}
  20. address {{ ip }}/{{ netmask }}
  21. {%- endfor %}
  22. {%- endif %} {#- dev-type tap #}
  23. {% endfor %} {#- network #}