Add radvd role

This commit is contained in:
Timotej Lazar 2025-07-31 12:15:48 +02:00
parent 7ffb1e7699
commit 0814e628c5
4 changed files with 42 additions and 0 deletions

1
roles/radvd/README.md Normal file
View file

@ -0,0 +1 @@
Install radvd and send out RAs on all interfaces where the configured IPv6 address is the gateway address for its prefix.

View file

@ -0,0 +1,5 @@
- name: reload radvd
service:
name: radvd
state: reloaded
when: "'handler' not in ansible_skip_tags"

View file

@ -0,0 +1,16 @@
- name: Install packages
package:
name:
- radvd
- name: Configure radvd
template:
dest: /etc/radvd.conf
src: radvd.conf.j2
notify: reload radvd
- name: Enable radvd service
service:
name: radvd
enabled: true
state: started

View file

@ -0,0 +1,20 @@
{% for iface in interfaces
| defaultattr('mgmt_only') | rejectattr('mgmt_only')
| selectattr('enabled') %}
{% for address in iface.ip_addresses | selectattr("family.value", "==", 6) %}
{# get the gateway for this subnet #}
{% set subnet = address.address | ipaddr('subnet') %}
{% set prefix = prefixes | selectattr('prefix', '==', subnet) | first %}
{% set gateway = prefix.custom_fields.gateway.address %}
{# if we are gateway, send RAs on this interface #}
{% if gateway is defined and gateway == address.address %}
interface {{ iface.name }} {
AdvSendAdvert on;
prefix ::/64;
RDNSS {{ dns6 | join(' ') }} { };
DNSSL {{ domain }} { };
};
{% endif %}
{% endfor %}
{% endfor %}