|
|
@ -74,6 +74,10 @@ examples:
|
|
|
|
notes:
|
|
|
|
notes:
|
|
|
|
- While it is possible to add an I(option) without specifying a I(value), this makes
|
|
|
|
- While it is possible to add an I(option) without specifying a I(value), this makes
|
|
|
|
no sense.
|
|
|
|
no sense.
|
|
|
|
|
|
|
|
- A section named C(default) cannot be added by the module, but if it exists, individual
|
|
|
|
|
|
|
|
options within the section can be updated. (This is a limitation of Python's I(ConfigParser).)
|
|
|
|
|
|
|
|
Either use M(template) to create a base INI file with a C([default]) section, or use
|
|
|
|
|
|
|
|
M(lineinfile) to add the missing line.
|
|
|
|
requirements: [ ConfigParser ]
|
|
|
|
requirements: [ ConfigParser ]
|
|
|
|
author: Jan-Piet Mens
|
|
|
|
author: Jan-Piet Mens
|
|
|
|
'''
|
|
|
|
'''
|
|
|
@ -112,6 +116,9 @@ def do_ini(module, filename, section=None, option=None, value=None, state='prese
|
|
|
|
|
|
|
|
|
|
|
|
if state == 'present':
|
|
|
|
if state == 'present':
|
|
|
|
if cp.has_section(section) == False:
|
|
|
|
if cp.has_section(section) == False:
|
|
|
|
|
|
|
|
if section.upper() == 'DEFAULT':
|
|
|
|
|
|
|
|
module.fail_json(msg="[DEFAULT] is an illegal section name")
|
|
|
|
|
|
|
|
|
|
|
|
cp.add_section(section)
|
|
|
|
cp.add_section(section)
|
|
|
|
changed = True
|
|
|
|
changed = True
|
|
|
|
|
|
|
|
|
|
|
@ -121,6 +128,9 @@ def do_ini(module, filename, section=None, option=None, value=None, state='prese
|
|
|
|
if str(value) != str(oldvalue):
|
|
|
|
if str(value) != str(oldvalue):
|
|
|
|
cp.set(section, option, value)
|
|
|
|
cp.set(section, option, value)
|
|
|
|
changed = True
|
|
|
|
changed = True
|
|
|
|
|
|
|
|
except ConfigParser.NoSectionError:
|
|
|
|
|
|
|
|
cp.set(section, option, value)
|
|
|
|
|
|
|
|
changed = True
|
|
|
|
except ConfigParser.NoOptionError:
|
|
|
|
except ConfigParser.NoOptionError:
|
|
|
|
cp.set(section, option, value)
|
|
|
|
cp.set(section, option, value)
|
|
|
|
changed = True
|
|
|
|
changed = True
|
|
|
|