From 05386153cc68c10c1af78709b576ab35b93dacd3 Mon Sep 17 00:00:00 2001 From: Jason DeTiberus Date: Wed, 20 May 2015 14:00:16 -0400 Subject: Guard against missing aws metadata for hostnames/ips --- roles/openshift_facts/library/openshift_facts.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'roles/openshift_facts') diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index ec27b5697..9c2657ff2 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -200,7 +200,7 @@ def normalize_aws_facts(metadata, facts): int_info = dict() var_map = {'ips': 'local-ipv4s', 'public_ips': 'public-ipv4s'} for ips_var, int_var in var_map.iteritems(): - ips = interface[int_var] + ips = interface.get(int_var) if isinstance(ips, basestring): int_info[ips_var] = [ips] else: @@ -220,14 +220,14 @@ def normalize_aws_facts(metadata, facts): # TODO: actually attempt to determine default local and public ips # by using the ansible default ip fact and the ipv4-associations # from the ec2 metadata - facts['network']['ip'] = metadata['local-ipv4'] - facts['network']['public_ip'] = metadata['public-ipv4'] + facts['network']['ip'] = metadata.get('local-ipv4') + facts['network']['public_ip'] = metadata.get('public-ipv4') # TODO: verify that local hostname makes sense and is resolvable - facts['network']['hostname'] = metadata['local-hostname'] + facts['network']['hostname'] = metadata.get('local-hostname') # TODO: verify that public hostname makes sense and is resolvable - facts['network']['public_hostname'] = metadata['public-hostname'] + facts['network']['public_hostname'] = metadata.get('public-hostname') return facts -- cgit v1.2.3