allow to template bird configs

main
n0emis 3 years ago
parent ddb126248f
commit 90249ad430
Signed by: n0emis
GPG Key ID: 00FAF748B777CF10

@ -16,13 +16,16 @@ dn42_roa_v6_location: "/etc/bird/roa_dn42_v6.conf"
dn42_roa_cronjob: "curl -sfSLR -o{{ dn42_roa_v4_location }} -z{{ dn42_roa_v4_location }} {{ dn42_roa_v4_source }} && curl -sfSLR -o{{ dn42_roa_v6_location }} -z{{ dn42_roa_v6_location }} {{ dn42_roa_v6_source }} && birdc configure"
dn42_pingfinder_enable: no
dn42_pingfinder_download_url: "https://git.dn42.us/dn42/pingfinder/raw/master/clients/generic-linux-debian-redhat-busybox.sh"
dn42_pingfinder_download_url: "https://dn42.us/peers/script"
dn42_pingfinder_location: "/usr/bin/dn42_pingfinder"
dn42_pingfinder_uuid: ""
dn42_pingfinder_logfile: "/dev/null"
dn42_configure_linux_network_table: no
dn42_bird2_template: "bird2/bird.conf.j2"
dn42_bird2_peer_template: "bird2/peer.conf.j2"
dn42_peers:
- name: "neighbour"
as: "4242424242"

@ -8,7 +8,7 @@
- name: Copy bird config-file
template:
dest: /etc/bird/bird.conf
src: "bird2/bird.conf.j2"
src: "{{ dn42_bird2_template }}"
notify: reload bird
- name: Ensure birds peer foler exists
@ -21,7 +21,7 @@
- name: Copy birds peer config-files
template:
dest: "/etc/bird/peers/{{ peer.name }}.conf"
src: "bird2/peer.conf.j2"
src: "{{ dn42_bird2_peer_template }}"
when: (not peer.state is defined) or peer.state != "absent"
loop: "{{ dn42_peers }}"
loop_control:

@ -7,8 +7,20 @@
group: "root"
mode: "0755"
- name: Set pingfinder UUID
cron:
name: "UUID"
job: "{{ dn42_pingfinder_uuid }}"
env: yes
- name: Set pingfinder LOGFILE
cron:
name: "LOGFILE"
job: "{{ dn42_pingfinder_logfile }}"
env: yes
- name: Add Pingfinder Cronjob
cron:
name: Run Pingfinder
job: "UUID={{ dn42_pingfinder_uuid }} LOGFILE={{ dn42_pingfinder_logfile }} {{ dn42_pingfinder_location }}"
job: "{{ dn42_pingfinder_location }}"
minute: "*/5"

@ -1,7 +1,24 @@
{%- set ifname = peer.if.name | default(dn42_wg_default_if_prefix + peer.name) -%}
{%- set localv4 = peer.if.v4 | default(dn42_local_v4) -%}
{%- set localv6 = peer.if.v6 | default(dn42_local_v6) -%}
{%- if dn42_configure_linux_network_table -%}
{%- set table = "42" -%}
{%- else -%}
{%- set table = "main" -%}
{%- endif -%}
[Interface]
PrivateKey = {{ peer.wg.privkey | default(dn42_wg_private_key) }}
Address = {{ peer.if.v4 | default(dn42_local_v4) }}/32, {{ peer.if.v6 | default(dn42_local_v6) }}/128
PostUp = {% if peer.v4 is defined %}/sbin/ip addr del dev {{ peer.if.name | default(dn42_wg_default_if_prefix + peer.name) }} {{ peer.if.v4 | default(dn42_local_v4) }}/32 && /sbin/ip addr add dev {{ peer.if.name | default(dn42_wg_default_if_prefix + peer.name) }} {{ peer.if.v4 | default(dn42_local_v4) }}/32 peer {{ peer.v4 }}/32 && {% endif %}{% if peer.v6 is defined %}/sbin/ip addr del dev {{ peer.if.name | default(dn42_wg_default_if_prefix + peer.name) }} {{ peer.if.v6 | default(dn42_local_v6) }}/128 && /sbin/ip addr add dev {{ peer.if.name | default(dn42_wg_default_if_prefix + peer.name) }} {{ peer.if.v6 | default(dn42_local_v6) }}/128 peer {{ peer.v6 }}/128{% endif %}
Address = {{ localv4 }}/32, {{ localv6 }}/128
PostUp = {% if peer.v4 is defined -%}
/sbin/ip addr del dev {{ ifname }} {{ localv4 }}/32 && {# ... -#}
/sbin/ip addr add dev {{ ifname }} {{ localv4 }}/32 peer {{ peer.v4 }}/32
{%- if peer.v6 is defined %} && {% endif -%}
{%- endif %}{% if peer.v6 is defined -%}
/sbin/ip addr del dev {{ ifname }} {{ localv6 }}/128 && {# ... -#}
/sbin/ip addr add dev {{ ifname }} {{ localv6 }}/128 peer {{ peer.v6 }}/128 && {# ... -#}
ip -6 r add {{ peer.v6 }}/128 dev {{ ifname }} table {{ table }} || true
{%- endif %}
Table = off
ListenPort = {{ peer.wg.port }}

Loading…
Cancel
Save