MEschenbacher's Wireguard Saltstack Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 line
1.3KB

  1. {%- macro output_if_set(object, lookup_key, output_key) %}
  2. {%- if object.get(lookup_key) %}
  3. {{output_key}} = {{object.get('lookup_key')}}
  4. {%- endif %}
  5. {%- endmacro %}
  6. {%- macro output_list_if_set(lookup_key, output_key) %}
  7. {%- for item in object.get(lookup_key, []) %}
  8. {{output_key}} = {{item}}
  9. {%- endfor %}
  10. {%- endmacro %}
  11. [Interface]
  12. {{ output_list_if_set(interface, 'address', 'Address') }}
  13. {{ output_if_set(interface, 'listenport', 'ListenPort') }}
  14. {{ output_list_if_set(interface, 'dns', 'DNS') }}
  15. {{ output_if_set(interface, 'mtu', 'MTU') }}
  16. {{ output_if_set(interface, 'privatekey', 'PrivateKey') }}
  17. {{ output_if_set(interface, 'table', 'Table') }}
  18. {{ output_if_set(interface, 'preup', 'PreUp') }}
  19. {{ output_if_set(interface, 'postup', 'PostUp') }}
  20. {{ output_if_set(interface, 'predown', 'PreDown') }}
  21. {{ output_if_set(interface, 'postdown', 'PostDown') }}
  22. {{ output_if_set(interface, 'saveconfig', 'SaveConfig') }}
  23. {{ output_if_set(interface, 'fwmark', 'FwMark') }}
  24. {%- for peer in interface.get('peers', []) %}
  25. [Peer]
  26. {{ output_if_set(peer, 'publickey', 'PublicKey') }}
  27. {{ output_if_set(peer, 'presharedkey', 'PresharedKey') }}
  28. {{ output_list_if_set(peer, 'allowedips', 'AllowedIPs') }}
  29. {{ output_if_set(peer, 'endpoint', 'Endpoint') }}
  30. {{ output_if_set(peer, 'persistentkeepalive', 'PersistentKeepalive') }}
  31. {%- endfor %}