[FIX] hostname should not have hyphens

This commit is contained in:
Jannik Beyerstedt 2020-07-18 23:41:21 +02:00
parent 3e9ece5237
commit c4e3a9e407
4 changed files with 9 additions and 9 deletions

View file

@ -1,10 +1,10 @@
--- ---
# defaults file for tinc # defaults file for tinc
tinc_base_dir: /etc/tinc tinc_base_dir: /etc/tinc
tinc_tmp_pubkey: "tmp/rsa_key-{{ ansible_hostname }}.pub" tinc_tmp_pubkey: "tmp/rsa_key-{{ ansible_hostname | replace('-', '_') }}.pub"
# ID of the vpn to create # ID of the vpn to create
tinc_vpn_id: vpn0 tinc_vpn_id: vpn0
# hostname of the always-on server # hostname of the always-on server
tinc_central_host: hetzner-01 tinc_central_host: hetzner_01

View file

@ -38,14 +38,14 @@
become: yes become: yes
fetch: fetch:
src: "{{ tinc_base_dir }}/{{ tinc_vpn_id }}/rsa_key.pub" src: "{{ tinc_base_dir }}/{{ tinc_vpn_id }}/rsa_key.pub"
dest: "{{ role_path }}/templates/tmp/rsa_key-{{ ansible_hostname }}.pub" dest: "{{ role_path }}/templates/tmp/rsa_key-{{ ansible_hostname | replace('-', '_') }}.pub"
flat: yes flat: yes
- name: Main - Create own hostfile - name: Main - Create own hostfile
become: yes become: yes
template: template:
src: "{{ role_path }}/templates/hostfile.j2" src: "{{ role_path }}/templates/hostfile.j2"
dest: "{{ tinc_base_dir }}/{{ tinc_vpn_id }}/hosts/{{ ansible_hostname }}" dest: "{{ tinc_base_dir }}/{{ tinc_vpn_id }}/hosts/{{ ansible_hostname | replace('-', '_') }}"
- name: Main - Create tinc-up script - name: Main - Create tinc-up script
become: yes become: yes
@ -64,8 +64,8 @@
- name: Main - Fetch all hostfiles - name: Main - Fetch all hostfiles
become: yes become: yes
fetch: fetch:
src: "{{ tinc_base_dir }}/{{ tinc_vpn_id }}/hosts/{{ ansible_hostname }}" src: "{{ tinc_base_dir }}/{{ tinc_vpn_id }}/hosts/{{ ansible_hostname | replace('-', '_') }}"
dest: "{{ role_path }}/files/tmp/{{ ansible_hostname }}" dest: "{{ role_path }}/files/tmp/{{ ansible_hostname | replace('-', '_') }}"
flat: yes flat: yes
- name: "Main - Enable {{ tinc_vpn_id }}" - name: "Main - Enable {{ tinc_vpn_id }}"

View file

@ -16,7 +16,7 @@ iptables -t nat -A POSTROUTING -o eth0 -s {{ tinc_vpn_net }} -j MASQUERADE
{% elif ansible_os_family == 'Darwin' %} {% elif ansible_os_family == 'Darwin' %}
# only a single endpoint works, because tun interface is p2p # only a single endpoint works, because tun interface is p2p
/sbin/ifconfig tun0 inet {{ tinc_client_ip | ipaddr('address') }} {{ tinc_remote_nets[0].gateway }} up netmast 255.255.255.0 /sbin/ifconfig tun0 inet {{ tinc_client_ip | ipaddr('address') }} {{ tinc_remote_nets[0].gateway }} up netmask 255.255.255.0
/sbin/route -n add -net {{ tinc_remote_nets[0].net_cidr }} {{ tinc_remote_nets[0].gateway }} /sbin/route -n add -net {{ tinc_remote_nets[0].net_cidr }} {{ tinc_remote_nets[0].gateway }}

View file

@ -1,8 +1,8 @@
Name = {{ ansible_hostname }} Name = {{ ansible_hostname | replace('-', '_') }}
{% if (override_os_family is defined) | ternary(override_os_family,ansible_os_family) != 'Darwin' %} {% if (override_os_family is defined) | ternary(override_os_family,ansible_os_family) != 'Darwin' %}
Device = /dev/net/tun Device = /dev/net/tun
{% endif %} {% endif %}
{% if ansible_hostname != tinc_central_host %} {% if ansible_hostname | replace('-', '_') != tinc_central_host %}
ConnectTo = {{ tinc_central_host }} ConnectTo = {{ tinc_central_host }}
{% endif %} {% endif %}
AddressFamily = any AddressFamily = any