diff options
author | Brian Coca <brian.coca+git@gmail.com> | 2015-11-10 22:22:08 +0100 |
---|---|---|
committer | Brian Coca <brian.coca+git@gmail.com> | 2015-11-10 22:22:45 +0100 |
commit | 37ae2435878b7dd76b812328878be620a93a30c9 (patch) | |
tree | 4afe15c211c257d151fe4caa677b1bc90bb2b5ab /lib | |
parent | Merge pull request #13100 from ghislainbourgeois/patch-2 (diff) | |
download | ansible-37ae2435878b7dd76b812328878be620a93a30c9.tar.xz ansible-37ae2435878b7dd76b812328878be620a93a30c9.zip |
made get_file_lines rely on get_file_content which deals with many error
conditions that the former did not.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ansible/module_utils/facts.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index d7105b5a87..4120a51fb5 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -2982,12 +2982,13 @@ def get_file_content(path, default=None, strip=True): return data def get_file_lines(path): - '''file.readlines() that closes the file''' - datafile = open(path) - try: - return datafile.readlines() - finally: - datafile.close() + '''get list of lines from file''' + data = get_file_content(path) + if data: + ret = data.splitlines() + else: + ret = [] + return ret def ansible_facts(module): facts = {} |