INI file without sections

The standard /etc/php.d/opcache.ini file is in ini format yet has no sections. If I try to use the ini_file module to change one value (say opcache.memory_consumption) without specifying some sort of “section=” it fails because I didn’t do so (so far ok, as that matches the documentation), but if I do specify “section=” with nothing following the equals sign it core dumps:

TASK: [setup opcache] *********************************************************
fatal: [gandalf-new.umcs.maine.edu] => failed to parse: Traceback (most recent call last):
File “/home/ansible/.ansible/tmp/ansible-1375815734.01-249448475333554/ini_file”, line 1079, in
main()
File “/home/ansible/.ansible/tmp/ansible-1375815734.01-249448475333554/ini_file”, line 176, in main
changed = do_ini(module, dest, section, option, value, state, backup)
File “/home/ansible/.ansible/tmp/ansible-1375815734.01-249448475333554/ini_file”, line 98, in do_ini
cp.readfp(f)
File “/usr/lib64/python2.6/ConfigParser.py”, line 305, in readfp
self._read(fp, filename)
File “/usr/lib64/python2.6/ConfigParser.py”, line 482, in _read
raise MissingSectionHeaderError(fpname, lineno, line)
ConfigParser.MissingSectionHeaderError: File contains no section headers.
file: /etc/php.d/opcache.ini, line: 2
‘zend_extension=/usr/lib64/php/modules/opcache.so\n’

YAML fragment from the play:

  • name: setup opcache
    ini_file: dest=/etc/php.d/opcache.ini
    option=opcache.memory_consumption
    value=256
    section=

Given that there’s a fair number of things I’ve run across that use INI formatted files WITHOUT sections, I was hoping I could work with these WITHOUT using the template module.

(Running version 1.2.2)

Right now this uses config parser so it would need to be updated to not use config parser.

I’m inclined to believe that might be more trouble than it is worth.

Hi

I have written a module to handle this bit - https://github.com/ritzk/ansible-modules-extras . reviews/feedback would be welcome.

Thanks
-ritz