2092bd06cb
add inventory exemple in readme
44 lines
1.8 KiB
Django/Jinja
44 lines
1.8 KiB
Django/Jinja
#jinja2: lstrip_blocks:"True",trim_blocks:"True"
|
|
[Interface]
|
|
Address = {{hostvars[inventory_hostname].wireguard_address}}
|
|
PrivateKey = {{private_key}}
|
|
ListenPort = {{wireguard_port}}
|
|
{% if hostvars[inventory_hostname].wireguard_dns is defined %}
|
|
DNS = {{hostvars[inventory_hostname].wireguard_dns}}
|
|
{% endif %}
|
|
{% if hostvars[inventory_hostname].wireguard_postup is defined %}
|
|
PostUp = {{hostvars[inventory_hostname].wireguard_postup}}
|
|
{% endif %}
|
|
{% if hostvars[inventory_hostname].wireguard_postdown is defined %}
|
|
PostDown = {{hostvars[inventory_hostname].wireguard_postdown}}
|
|
{% endif %}
|
|
{% if hostvars[inventory_hostname].wireguard_save_config is defined %}
|
|
SaveConfig = true
|
|
{% endif %}
|
|
|
|
{% for host in ansible_play_hosts %}
|
|
{% if host != inventory_hostname %}
|
|
[Peer]
|
|
PublicKey = {{hostvars[host].public_key}}
|
|
{% if hostvars[host].wireguard_allowed_ips is defined %}
|
|
AllowedIPs = {{hostvars[host].wireguard_allowed_ips}}
|
|
{% else %}
|
|
AllowedIPs = {{hostvars[host].wireguard_ip}}/32
|
|
{% endif %}
|
|
{% if hostvars[host].wireguard_persistent_keepalive is defined %}
|
|
PersistentKeepalive = {{hostvars[host].wireguard_persistent_keepalive}}
|
|
{% endif %}
|
|
{% if hostvars[host].wireguard_port is defined and hostvars[host].wireguard_port is number %}
|
|
{% if hostvars[host].wireguard_endpoint is defined and hostvars[host].wireguard_endpoint != "" %}
|
|
Endpoint = {{hostvars[host].wireguard_endpoint}}:{{hostvars[host].wireguard_port}}
|
|
{% else %}
|
|
Endpoint = {{host}}:{{hostvars[host].wireguard_port}}
|
|
{% endif %}
|
|
{% elif hostvars[host].wireguard_endpoint is defined and hostvars[host].wireguard_endpoint != "" %}
|
|
Endpoint = {{hostvars[host].wireguard_endpoint}}:51820
|
|
{% else %}
|
|
Endpoint = {{host}}:51820
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endfor %}
|