Merge branch 'blxd-feature/ini_file_change_mode_support' into devel

reviewable/pr18780/r1
James Cammarata 10 years ago
commit b5c1b9b8f9

@ -126,7 +126,7 @@ def do_ini(module, filename, section=None, option=None, value=None, state='prese
if state == 'present': if state == 'present':
# DEFAULT section is always there by DEFAULT, so never try to add it. # DEFAULT section is always there by DEFAULT, so never try to add it.
if cp.has_section(section) == False and section.upper() != 'DEFAULT': if not cp.has_section(section) and section.upper() != 'DEFAULT':
cp.add_section(section) cp.add_section(section)
changed = True changed = True
@ -144,7 +144,7 @@ def do_ini(module, filename, section=None, option=None, value=None, state='prese
cp.set(section, option, value) cp.set(section, option, value)
changed = True changed = True
if changed: if changed and not module.check_mode:
if backup: if backup:
module.backup_local(filename) module.backup_local(filename)
@ -152,7 +152,7 @@ def do_ini(module, filename, section=None, option=None, value=None, state='prese
f = open(filename, 'w') f = open(filename, 'w')
cp.write(f) cp.write(f)
except: except:
module.fail_json(msg="Can't creat %s" % filename) module.fail_json(msg="Can't create %s" % filename)
return changed return changed
@ -183,7 +183,8 @@ def main():
backup = dict(default='no', type='bool'), backup = dict(default='no', type='bool'),
state = dict(default='present', choices=['present', 'absent']) state = dict(default='present', choices=['present', 'absent'])
), ),
add_file_common_args = True add_file_common_args = True,
supports_check_mode = True
) )
info = dict() info = dict()

Loading…
Cancel
Save