INI file without sections

1,419 views
Skip to first unread message

Drew Northup

unread,
Aug 6, 2013, 3:20:16 PM8/6/13
to ansible...@googlegroups.com
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 <module>
    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)

--
---------------------------------+--------------------------------------
Drew Northup                     |          Technical Support Specialist
University of Maine System       |                Drew.N...@Maine.edu
Computing Center                 |                 phone: (207) 561-3513
Orono, ME 04469                  |                   fax: (207) 561-3531

Michael DeHaan

unread,
Aug 6, 2013, 5:44:50 PM8/6/13
to ansible...@googlegroups.com
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.




--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Michael DeHaan <mic...@ansibleworks.com>
CTO, AnsibleWorks, Inc.
http://www.ansibleworks.com/

Ritesh Khadgaray

unread,
Jun 24, 2015, 3:37:52 PM6/24/15
to ansible...@googlegroups.com
Hi

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

Thanks
-ritz
Reply all
Reply to author
Forward
0 new messages