Handle omitted variables which appear as empty strings

Changes to external roles cause some variables to be passed in
as empty strings which result in invalid config and InvalidArgument
errors.

This could be addressed here or in the calling role.

Change-Id: Iee71e9839d4c8d318c2c36152d966dd5a1b88111
This commit is contained in:
Andrew Bonney 2023-01-10 15:05:13 +00:00
parent 5acf51aec3
commit 4a7012e366
1 changed files with 2 additions and 2 deletions

View File

@ -40,7 +40,7 @@ DHCP=yes
{% set _addr_cidr = (_addr.address ~ '/' ~ _addr.netmask | default('')).rstrip('/') | ansible.utils.ipaddr('host') %}
Address={{ _addr_cidr }}
{% endif %}
{% if _addr.gateway is defined %}
{% if _addr.gateway is defined and (_addr.gateway | length) > 0 %}
Gateway={{ item.1.gateway }}
{% endif %}
{% endfor %}
@ -66,6 +66,6 @@ IPForward={{ (item.1.ipforward | bool) | ternary('yes', 'no') }}
{% endif %}
[Link]
{% if item.1.mtu is defined %}
{% if item.1.mtu is defined and item.1.mtu %}
MTUBytes={{ item.1.mtu }}
{% endif %}