Drop redundant use of `hostvars[inventory_hostname].` prefix

Those variables are directly in the namespace. Using the long form is
uncommon. A case could have been made if the later section of the config
(which uses `hostvars[host]`) has similar semantics but that is not the
case as those are peer sections.
master
Robin Schneider 4 years ago
parent a27f805d2d
commit 132c59521a
No known key found for this signature in database
GPG Key ID: A81E8006DC95EFE6

@ -3,42 +3,42 @@
[Interface]
# {{ inventory_hostname }}
Address = {{hostvars[inventory_hostname].wireguard_address}}
Address = {{wireguard_address}}
PrivateKey = {{ wireguard__fact_private_key }}
ListenPort = {{ wireguard_port }}
{% if hostvars[inventory_hostname].wireguard_dns is defined %}
DNS = {{hostvars[inventory_hostname].wireguard_dns}}
{% if wireguard_dns is defined %}
DNS = {{wireguard_dns}}
{% endif %}
{% if hostvars[inventory_hostname].wireguard_fwmark is defined %}
FwMark = {{hostvars[inventory_hostname].wireguard_fwmark}}
{% if wireguard_fwmark is defined %}
FwMark = {{wireguard_fwmark}}
{% endif %}
{% if hostvars[inventory_hostname].wireguard_mtu is defined %}
MTU = {{hostvars[inventory_hostname].wireguard_mtu}}
{% if wireguard_mtu is defined %}
MTU = {{wireguard_mtu}}
{% endif %}
{% if hostvars[inventory_hostname].wireguard_table is defined %}
Table = {{hostvars[inventory_hostname].wireguard_table}}
{% if wireguard_table is defined %}
Table = {{wireguard_table}}
{% endif %}
{% if hostvars[inventory_hostname].wireguard_preup is defined %}
{% for wg_preup in hostvars[inventory_hostname].wireguard_preup %}
{% if wireguard_preup is defined %}
{% for wg_preup in wireguard_preup %}
PreUp = {{ wg_preup }}
{% endfor %}
{% endif %}
{% if hostvars[inventory_hostname].wireguard_predown is defined %}
{% for wg_predown in hostvars[inventory_hostname].wireguard_predown %}
{% if wireguard_predown is defined %}
{% for wg_predown in wireguard_predown %}
PreDown = {{ wg_predown }}
{% endfor %}
{% endif %}
{% if hostvars[inventory_hostname].wireguard_postup is defined %}
{% for wg_postup in hostvars[inventory_hostname].wireguard_postup %}
{% if wireguard_postup is defined %}
{% for wg_postup in wireguard_postup %}
PostUp = {{ wg_postup }}
{% endfor %}
{% endif %}
{% if hostvars[inventory_hostname].wireguard_postdown is defined %}
{% for wg_postdown in hostvars[inventory_hostname].wireguard_postdown %}
{% if wireguard_postdown is defined %}
{% for wg_postdown in wireguard_postdown %}
PostDown = {{ wg_postdown }}
{% endfor %}
{% endif %}
{% if hostvars[inventory_hostname].wireguard_save_config is defined %}
{% if wireguard_save_config is defined %}
SaveConfig = true
{% endif %}
{% for host in ansible_play_hosts %}
@ -57,8 +57,8 @@ PersistentKeepalive = {{hostvars[host].wireguard_persistent_keepalive}}
{% endif %}
{% if (
hostvars[host].wireguard_dc is defined and
hostvars[inventory_hostname].wireguard_dc is defined and
hostvars[inventory_hostname].wireguard_dc['name'] != hostvars[host].wireguard_dc['name']
wireguard_dc is defined and
wireguard_dc['name'] != hostvars[host].wireguard_dc['name']
)
%}
Endpoint = {{hostvars[host].wireguard_dc['endpoint']}}:{{hostvars[host].wireguard_dc['port']}}

Loading…
Cancel
Save