From 78221b17d4f0e3b9da680066efcb48619f82fbeb Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Fri, 25 Jan 2019 22:55:03 -0600 Subject: [PATCH] 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 --- .../roles/skydive_common/templates/skydive-openssl.cnf.j2 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/skydive/roles/skydive_common/templates/skydive-openssl.cnf.j2 b/skydive/roles/skydive_common/templates/skydive-openssl.cnf.j2 index b3640e7b..b34e8f94 100644 --- a/skydive/roles/skydive_common/templates/skydive-openssl.cnf.j2 +++ b/skydive/roles/skydive_common/templates/skydive-openssl.cnf.j2 @@ -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 %}