Validate the IP addresses when generating a CNF

Before adding IP addresses to the CNF validate the entry is an IP
address using the `ipaddr` filter.

Change-Id: I9151b8118b92991b394c0fa7d81d407439f0f3c1
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter 2019-01-25 22:55:03 -06:00
parent 926695fbf1
commit 78221b17d4
No known key found for this signature in database
GPG Key ID: 9443251A787B9FB3
1 changed files with 5 additions and 1 deletions

View File

@ -29,9 +29,13 @@ subjectAltName = @alt_names
{% set _skydive_ip = hostvars[node]['skydive_bind_address'] | default(hostvars[node]["ansible_" ~ _ansible_interface_name]['ipv4']['address']) %}
{% set _skydive_ansible_domain = hostvars[node]['ansible_fqdn'] | default(hostvars[node]['ansible_hostname'] ) %}
{% set _skydive_dns_name = ((_skydive_ansible_domain | length) > 0) | ternary(_skydive_ansible_domain, hostvars[node]['ansible_hostname']) %}
{% set _ = ips.append(_skydive_ip) %}
{% if _skydive_ip | ipaddr %}
{% set _ = ips.append(_skydive_ip) %}
{% endif %}
{% set _ = hostnames.append(_skydive_dns_name) %}
{% if _skydive_ip | ipaddr %}
IP.{{ loop.index }} = {{ _skydive_ip }}
{% endif %}
DNS.{{ loop.index }} = {{ _skydive_dns_name }}
{% endif %}
{% endfor %}