From 762135915cc48e0560c3cbe90316931caf6fd965 Mon Sep 17 00:00:00 2001 From: Robert Parrott Date: Thu, 10 Oct 2013 09:01:00 -0400 Subject: [PATCH 1/2] fix handling of [DEFAULT] section by ConfigParser. it is there by DEFAULT. --- library/files/ini_file | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/files/ini_file b/library/files/ini_file index c0c2fe54e9..a699053ede 100644 --- a/library/files/ini_file +++ b/library/files/ini_file @@ -116,11 +116,11 @@ def do_ini(module, filename, section=None, option=None, value=None, state='prese pass if state == 'present': - if cp.has_section(section) == False: - if section.upper() == 'DEFAULT': - module.fail_json(msg="[DEFAULT] is an illegal section name") - cp.add_section(section) + if cp.has_section(section) == False: + + if section.upper() != 'DEFAULT': + cp.add_section(section) changed = True if option is not None and value is not None: From 54aeaaf486e6c781d6c4a6a70067ae56711a793f Mon Sep 17 00:00:00 2001 From: Robert Parrott Date: Thu, 10 Oct 2013 09:10:00 -0400 Subject: [PATCH 2/2] small change ... in order to get changed signal correct, move DEFAULT section test upward. --- library/files/ini_file | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/files/ini_file b/library/files/ini_file index a699053ede..7634a3b696 100644 --- a/library/files/ini_file +++ b/library/files/ini_file @@ -117,10 +117,10 @@ def do_ini(module, filename, section=None, option=None, value=None, state='prese if state == 'present': - if cp.has_section(section) == False: + # DEFAULT section is always there by DEFAULT, so never try to add it. + if cp.has_section(section) == False and section.upper() != 'DEFAULT': - if section.upper() != 'DEFAULT': - cp.add_section(section) + cp.add_section(section) changed = True if option is not None and value is not None: