Because the logic places the network statement under address-family:
{% macro render_ipv4_network_configs(ipv4_network_vars) %}
{% for net in ipv4_network_vars %}
{% if net.address is defined and net.address %}
{% if net.state is defined and net.state == "absent"%}
no network {{ net.address }}
{% else %}
network {{ net.address }}
{% endif %}
{% endif %}
{% endfor %}
{% endmacro %}
{% if vrf.ipv4_network is defined and vrf.ipv4_network %}
{% set ipv4_network_vars = vrf.ipv4_network %}
address-family ipv4 unicast
{{ render_ipv4_network_configs(ipv4_network_vars) }}
{% endif %}
The issue here is that, when placing the configuration under absent:
You will get the following error message:
fatal: [xxx]: FAILED! => {"changed": false, "command": "no network 1.1.1.0/24", "msg": "no network 1.1.1.0/24\r\n% Error: Unrecognized command.\r\n\u0007xxx(config-router-bgp-xxx-vrf)# ", "rc": -32603}
This is because it's not deleting it under the address family. but under the vrf.
If you compare this with aggregate address it is working because that's actually placed under the correct spot allready:
{% macro render_af_configs(af_vars) %}
{% if af_vars is defined and af_vars %}
{% if af_vars.aggregate_address is defined and af_vars.aggregate_address %}
{% for addr in af_vars.aggregate_address %}
{% if addr.ip_and_mask is defined and addr.ip_and_mask %}
{% if addr.state is defined and addr.state == "absent" %}
no aggregate-address {{ addr.ip_and_mask }}
{% else %}
{% set aggr_str = addr.ip_and_mask %}
{% if addr.adv_map is defined and addr.adv_map %}
{% set aggr_str = aggr_str ~ " advertise-map " ~ addr.adv_map %}
{% endif %}
{% if addr.as_set is defined and addr.as_set %}
{% set aggr_str = aggr_str ~ " as-set " %}
{% endif %}
{% if addr.attr_map is defined and addr.attr_map %}
{% set aggr_str = aggr_str ~ " attribute-map " ~ addr.attr_map %}
{% endif %}
{% if addr.summary is defined and addr.summary %}
{% set aggr_str = aggr_str ~ " summary-only" %}
{% endif %}
{% if addr.suppress_map is defined and addr.suppress_map %}
{% set aggr_str = aggr_str ~ " suppress-map " ~ addr.suppress_map %}
{% endif %}
aggregate-address {{ aggr_str }}
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
{% endmacro %}
The following yaml Configuration,
results in:
Because the logic places the network statement under address-family:
The issue here is that, when placing the configuration under absent:
You will get the following error message: fatal: [xxx]: FAILED! => {"changed": false, "command": "no network 1.1.1.0/24", "msg": "no network 1.1.1.0/24\r\n% Error: Unrecognized command.\r\n\u0007xxx(config-router-bgp-xxx-vrf)# ", "rc": -32603}
This is because it's not deleting it under the address family. but under the vrf.
If you compare this with aggregate address it is working because that's actually placed under the correct spot allready:
results in:
and:
results in:
Can you guys please fix this?