MEschenbacher's Wireguard Saltstack Formula
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

36 行
1.4KB

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