iptables: handle hosts in allowed groups not having an ipv6 address
The modified section of the rules.v6 template looks at the groups in the iptables_allowed_groups list and then allows access for each host specified in that group. Currently this extracts the 'public_v6' from the hostvars[host] directly, but this fails if the host in question doesn't actually have an ipv6 address. Modify this so we check if the variable exists, and then reference it via the hostvars dict. Note that in gate testing, ipv6 may be empty string (set from nodepool values), while it may not be a value at all if it is left out of the production inventory. "hostvars[host]['public_v6'] | default(False)" should catch both cases. Change-Id: I90069efc7d72d881ec57670b9c6b426a8a5422a3
This commit is contained in:
parent
9344d8c046
commit
efa858c58e
@ -28,9 +28,9 @@
|
||||
{% endfor -%}
|
||||
{% endfor -%}
|
||||
{% for group in iptables_allowed_groups -%}
|
||||
{% for addr in groups.get(group.group) | map('extract', hostvars, 'public_v6') -%}
|
||||
{% if addr -%}
|
||||
-A openstack-INPUT {% if group.protocol == 'tcp' %}-m state --state NEW {% endif %} -m {{ group.protocol }} -p {{ group.protocol }} -s {{ addr }} --dport {{ group.port }} -j ACCEPT
|
||||
{% for host in groups.get(group.group, []) -%}
|
||||
{% if hostvars[host]['public_v6'] | default(False) -%}
|
||||
-A openstack-INPUT {% if group.protocol == 'tcp' %}-m state --state NEW {% endif %} -m {{ group.protocol }} -p {{ group.protocol }} -s {{ hostvars[host]['public_v6'] }} --dport {{ group.port }} -j ACCEPT
|
||||
{% endif -%}
|
||||
{% endfor -%}
|
||||
{% endfor -%}
|
||||
|
Loading…
Reference in New Issue
Block a user