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

Loading…
Cancel
Save