diff options
author | Brian Coca <brian.coca+git@gmail.com> | 2016-03-14 20:13:23 -0700 |
---|---|---|
committer | Brian Coca <brian.coca+git@gmail.com> | 2016-03-14 20:13:23 -0700 |
commit | f3b9449e079fd5403f25c18d7d71417a2fc0e639 (patch) | |
tree | 35d8a22d7517e9155d6659082e7f39db27c1df53 | |
parent | 051b9e7b907694934a2df74b5bb67ccf1e1d1820 (diff) | |
download | ansible-f3b9449e079fd5403f25c18d7d71417a2fc0e639.tar.gz |
don't raise exceptoins on bad hosts files
fixes #14969
-rw-r--r-- | lib/ansible/module_utils/facts.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index 1aa16c9fee..835ebd74d8 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -770,7 +770,8 @@ class Facts(object): for nameserver in tokens[1:]: self.facts['dns']['nameservers'].append(nameserver) elif tokens[0] == 'domain': - self.facts['dns']['domain'] = tokens[1] + if len(tokens) > 1: + self.facts['dns']['domain'] = tokens[1] elif tokens[0] == 'search': self.facts['dns']['search'] = [] for suffix in tokens[1:]: @@ -781,12 +782,13 @@ class Facts(object): self.facts['dns']['sortlist'].append(address) elif tokens[0] == 'options': self.facts['dns']['options'] = {} - for option in tokens[1:]: - option_tokens = option.split(':', 1) - if len(option_tokens) == 0: - continue - val = len(option_tokens) == 2 and option_tokens[1] or True - self.facts['dns']['options'][option_tokens[0]] = val + if len(tokens) > 1: + for option in tokens[1:]: + option_tokens = option.split(':', 1) + if len(option_tokens) == 0: + continue + val = len(option_tokens) == 2 and option_tokens[1] or True + self.facts['dns']['options'][option_tokens[0]] = val def _get_mount_size_facts(self, mountpoint): size_total = None |