From 0f7abad38f3b4558400fe20eb3742603f64b939c Mon Sep 17 00:00:00 2001 From: Alexandre Garnier Date: Wed, 7 Dec 2016 17:00:14 +0100 Subject: [PATCH] Fix python 2.4 compatibility `start` keyword of `enumerate` is only available since python 2.6 --- lib/ansible/modules/system/known_hosts.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/system/known_hosts.py b/lib/ansible/modules/system/known_hosts.py index 69210d9fdf2..258bcf7348e 100644 --- a/lib/ansible/modules/system/known_hosts.py +++ b/lib/ansible/modules/system/known_hosts.py @@ -145,8 +145,8 @@ def enforce_state(module, params): try: outf=tempfile.NamedTemporaryFile(dir=os.path.dirname(path)) if inf is not None: - for line_number, line in enumerate(inf, start=1): - if found_line==line_number and (replace_or_add or state=='absent'): + for line_number, line in enumerate(inf): + if found_line==(line_number + 1) and (replace_or_add or state=='absent'): continue # skip this line to replace its key outf.write(line) inf.close()