parent
223c689ec0
commit
a179d06a91
1 changed files with 15 additions and 15 deletions
|
@ -65,6 +65,12 @@ options:
|
||||||
description:
|
description:
|
||||||
- all arguments accepted by the M(file) module also work here
|
- all arguments accepted by the M(file) module also work here
|
||||||
required: false
|
required: false
|
||||||
|
state:
|
||||||
|
description:
|
||||||
|
- If set to C(absent) the option or section will be removed if present instead of created.
|
||||||
|
required: false
|
||||||
|
default: "present"
|
||||||
|
choices: [ "present", "absent" ]
|
||||||
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.
|
||||||
|
@ -110,21 +116,14 @@ def do_ini(module, filename, section=None, option=None, value=None, state='prese
|
||||||
|
|
||||||
|
|
||||||
if state == 'absent':
|
if state == 'absent':
|
||||||
if option is None and value is None:
|
if option is None:
|
||||||
if cp.has_section(section):
|
changed = cp.remove_section(section)
|
||||||
cp.remove_section(section)
|
|
||||||
changed = True
|
|
||||||
else:
|
else:
|
||||||
if option is not None:
|
try:
|
||||||
try:
|
changed = cp.remove_option(section, option)
|
||||||
if cp.get(section, option):
|
except ConfigParser.NoSectionError:
|
||||||
cp.remove_option(section, option)
|
# Option isn't present if the section isn't either
|
||||||
changed = True
|
pass
|
||||||
except ConfigParser.InterpolationError:
|
|
||||||
cp.remove_option(section, option)
|
|
||||||
changed = True
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
|
|
||||||
|
@ -212,4 +211,5 @@ def main():
|
||||||
|
|
||||||
# import module snippets
|
# import module snippets
|
||||||
from ansible.module_utils.basic import *
|
from ansible.module_utils.basic import *
|
||||||
main()
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
Loading…
Reference in a new issue