[TIDY] Move to ansible_facts dict instead of injected variables

This commit is contained in:
Jannik Beyerstedt 2025-12-20 21:01:23 +01:00
parent cdd9bc58d2
commit ccf581edaa
6 changed files with 20 additions and 20 deletions

View file

@ -1,14 +1,14 @@
#!/bin/sh
{% if ansible_hostname == 'hetzner-01' %}
{% if ansible_facts['hostname'] == 'hetzner-01' %}
/sbin/ifconfig $INTERFACE down
/usr/sbin/ip rule del to {{ tinc_remote_nets[0].net_cidr }} table 5
{% elif ansible_hostname == 'RaspiBeyerstedt' %}
{% elif ansible_facts['hostname'] == 'RaspiBeyerstedt' %}
/sbin/ifconfig $INTERFACE down
/bin/ip route del {{ tinc_remote_nets[0].net_cidr }} dev eth0
{% elif ansible_os_family == 'Darwin' %}
{% elif ansible_facts['os_family'] == 'Darwin' %}
/sbin/ifconfig $INTERFACE down
/sbin/route -n delete -net {{ tinc_remote_nets[0].net_cidr }} {{ tinc_remote_nets[0].gateway }}

View file

@ -1,12 +1,12 @@
#!/bin/sh
{% if ansible_hostname == 'hetzner-01' %}
{% if ansible_facts['hostname'] == 'hetzner-01' %}
/sbin/ifconfig $INTERFACE {{ tinc_client_ip | ipaddr('address') }} netmask 255.255.255.0
/usr/sbin/ip rule add to {{ tinc_remote_nets[0].net_cidr }} table 5
/usr/sbin/ip route add {{ tinc_remote_nets[0].net_cidr }} via {{ tinc_remote_nets[0].gateway }} dev {{ tinc_vpn_id }} table 5
{% elif ansible_hostname == 'RaspiBeyerstedt' %}
{% elif ansible_facts['hostname'] == 'RaspiBeyerstedt' %}
/sbin/ifconfig $INTERFACE {{ tinc_client_ip | ipaddr('address') }} netmask 255.255.255.0
/bin/bash -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
@ -14,7 +14,7 @@
iptables -t nat -A POSTROUTING -o eth0 -s {{ tinc_vpn_net }} -j MASQUERADE
{% elif ansible_os_family == 'Darwin' %}
{% elif ansible_facts['os_family'] == 'Darwin' %}
# only a single endpoint works, because tun interface is p2p
/sbin/ifconfig $INTERFACE inet {{ tinc_client_ip | ipaddr('address') }} {{ tinc_remote_nets[0].gateway }} up netmask 255.255.255.0

View file

@ -1,10 +1,10 @@
Name = {{ ansible_hostname | replace('-', '_') }}
{% if (override_os_family is defined) | ternary(override_os_family,ansible_os_family) != 'Darwin' %}
Name = {{ ansible_facts['hostname'] | replace('-', '_') }}
{% if (override_os_family is defined) | ternary(override_os_family,ansible_facts['os_family']) != 'Darwin' %}
Device = /dev/net/tun
{% elif ternary(override_os_family,ansible_os_family) == 'Darwin' %}
{% elif ternary(override_os_family,ansible_facts['os_family']) == 'Darwin' %}
DeviceType = utun
{% endif %}
{% if ansible_hostname | replace('-', '_') != tinc_central_host %}
{% if ansible_facts['hostname'] | replace('-', '_') != tinc_central_host %}
ConnectTo = {{ tinc_central_host }}
{% endif %}
AddressFamily = any