From 64fa95ca1112d7db6ede6fe77cba89cf813c1b9a Mon Sep 17 00:00:00 2001 From: Marcus McCurdy Date: Mon, 2 Sep 2013 11:14:40 -0400 Subject: [PATCH 1/2] Improves lineinfile's error checking Line in file would raise a TypeError exception if the 'line' key was in params, but its value was None. --- library/files/lineinfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/files/lineinfile b/library/files/lineinfile index 29ff9603fdf..7dd38a3cf05 100644 --- a/library/files/lineinfile +++ b/library/files/lineinfile @@ -305,7 +305,7 @@ def main(): module.fail_json(rc=256, msg='Destination %s is a directory !' % dest) if params['state'] == 'present': - if 'line' not in params: + if params.get('line') is None: module.fail_json(msg='line= is required with state=present') # Deal with the insertafter default value manually, to avoid errors From 46ff02bc574c6cb3fe267f109ec20e90b4928173 Mon Sep 17 00:00:00 2001 From: Marcus McCurdy Date: Mon, 2 Sep 2013 16:16:45 -0400 Subject: [PATCH 2/2] Makes pervious lineinfile fix more explicit --- library/files/lineinfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/files/lineinfile b/library/files/lineinfile index 7dd38a3cf05..d68b272a04a 100644 --- a/library/files/lineinfile +++ b/library/files/lineinfile @@ -305,7 +305,7 @@ def main(): module.fail_json(rc=256, msg='Destination %s is a directory !' % dest) if params['state'] == 'present': - if params.get('line') is None: + if params.get('line', None) is None: module.fail_json(msg='line= is required with state=present') # Deal with the insertafter default value manually, to avoid errors