diff --git a/roles/radvd/molecule/default/converge.yml b/roles/radvd/molecule/default/converge.yml index b06d14bd8a..edcbd5ceff 100644 --- a/roles/radvd/molecule/default/converge.yml +++ b/roles/radvd/molecule/default/converge.yml @@ -108,6 +108,21 @@ - "'AdvAutonomous on' in _config" - "'AdvRouterAddr on' in _config" + - name: Verify testnet1 configuration formatting is correct + vars: + _config_lines: "{{ (_testnet1_conf.content | b64decode).split('\n') }}" + ansible.builtin.assert: + that: + # Check directives are on separate lines (not squished together) + - _config_lines | select('match', '.*;.*AdvManagedFlag') | list | length == 0 + - _config_lines | select('match', '.*;.*AdvOtherConfigFlag') | list | length == 0 + - _config_lines | select('match', '.*;.*AdvLinkMTU') | list | length == 0 + # Check specific lines have proper formatting (one directive per line) + - _config_lines | select('match', '^ AdvManagedFlag on;$') | list | length == 1 + - _config_lines | select('match', '^ AdvOtherConfigFlag on;$') | list | length == 1 + - _config_lines | select('match', '^ AdvLinkMTU 1500;$') | list | length == 1 + msg: "Configuration formatting is incorrect - directives may be squished together on the same line" + - name: Verify testnet2 configuration has RDNSS become: true ansible.builtin.slurp: diff --git a/roles/radvd/templates/network.conf.j2 b/roles/radvd/templates/network.conf.j2 index d24aea65aa..e258e93be9 100644 --- a/roles/radvd/templates/network.conf.j2 +++ b/roles/radvd/templates/network.conf.j2 @@ -4,60 +4,60 @@ interface {{ cifmw_radvd_network.name }} { AdvSendAdvert {{ (cifmw_radvd_network.adv_send_advert | default(true)) | ternary('on', 'off') }}; -{%- if cifmw_radvd_network.adv_managed_flag is defined %} +{% if cifmw_radvd_network.adv_managed_flag is defined %} AdvManagedFlag {{ cifmw_radvd_network.adv_managed_flag | ternary('on', 'off') }}; -{%- endif %} -{%- if cifmw_radvd_network.adv_other_config_flag is defined %} +{% endif %} +{% if cifmw_radvd_network.adv_other_config_flag is defined %} AdvOtherConfigFlag {{ cifmw_radvd_network.adv_other_config_flag | ternary('on', 'off') }}; -{%- endif %} -{%- if cifmw_radvd_network.adv_ra_solicited_unicast is defined %} +{% endif %} +{% if cifmw_radvd_network.adv_ra_solicited_unicast is defined %} AdvRASolicitedUnicast {{ cifmw_radvd_network.adv_ra_solicited_unicast | ternary('on', 'off') }}; -{%- endif %} -{%- if cifmw_radvd_network.adv_link_mtu is defined %} +{% endif %} +{% if cifmw_radvd_network.adv_link_mtu is defined %} AdvLinkMTU {{ cifmw_radvd_network.adv_link_mtu }}; -{%- endif %} -{%- if cifmw_radvd_network.min_rtr_adv_interval is defined %} +{% endif %} +{% if cifmw_radvd_network.min_rtr_adv_interval is defined %} MinRtrAdvInterval {{ cifmw_radvd_network.min_rtr_adv_interval }}; -{%- endif %} -{%- if cifmw_radvd_network.max_rtr_adv_interval is defined %} +{% endif %} +{% if cifmw_radvd_network.max_rtr_adv_interval is defined %} MaxRtrAdvInterval {{ cifmw_radvd_network.max_rtr_adv_interval }}; -{%- endif %} -{%- for prefix in cifmw_radvd_network.prefixes | default([]) %} +{% endif %} +{% for prefix in cifmw_radvd_network.prefixes | default([]) %} prefix {{ prefix.network }} { AdvOnLink {{ (prefix.adv_on_link | default(true)) | ternary('on', 'off') }}; AdvAutonomous {{ (prefix.adv_autonomous | default(true)) | ternary('on', 'off') }}; -{%- if prefix.adv_router_addr is defined %} +{% if prefix.adv_router_addr is defined %} AdvRouterAddr {{ prefix.adv_router_addr | ternary('on', 'off') }}; -{%- endif %} -{%- if prefix.adv_valid_lifetime is defined %} +{% endif %} +{% if prefix.adv_valid_lifetime is defined %} AdvValidLifetime {{ prefix.adv_valid_lifetime }}; -{%- endif %} -{%- if prefix.adv_preferred_lifetime is defined %} +{% endif %} +{% if prefix.adv_preferred_lifetime is defined %} AdvPreferredLifetime {{ prefix.adv_preferred_lifetime }}; -{%- endif %} +{% endif %} }; -{%- endfor %} -{%- for route in cifmw_radvd_network.routes | default([]) %} +{% endfor %} +{% for route in cifmw_radvd_network.routes | default([]) %} route {{ route.network }} { -{%- if route.adv_route_preference is defined %} +{% if route.adv_route_preference is defined %} AdvRoutePreference {{ route.adv_route_preference }}; -{%- endif %} -{%- if route.adv_route_lifetime is defined %} +{% endif %} +{% if route.adv_route_lifetime is defined %} AdvRouteLifetime {{ route.adv_route_lifetime }}; -{%- endif %} +{% endif %} }; -{%- endfor %} -{%- for rdnss in cifmw_radvd_network.rdnss | default([]) %} +{% endfor %} +{% for rdnss in cifmw_radvd_network.rdnss | default([]) %} RDNSS {{ rdnss.servers | join(' ') }} { -{%- if rdnss.adv_rdnss_lifetime is defined %} +{% if rdnss.adv_rdnss_lifetime is defined %} AdvRDNSSLifetime {{ rdnss.adv_rdnss_lifetime }}; -{%- endif %} +{% endif %} }; -{%- endfor %} +{% endfor %} };