# INI file without sections

**URL:** <https://forum.ansible.com/t/ini-file-without-sections/13264>\
**Category:** Ansible Project\
**Created:** [August 6, 2013, 7:20pm UTC](https://forum.ansible.com/t/ini-file-without-sections/13264 "2013-08-06T19:20:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Drew\_Northup](https://avatars.discourse-cdn.com/v4/letter/d/e5b9ba/32.png) [@Drew\_Northup](https://forum.ansible.com/u/Drew_Northup)\
**Post date:** [August 6, 2013, 7:20pm UTC](https://forum.ansible.com/t/ini-file-without-sections/13264/1 "2013-08-06T19:20:16Z")

</div>

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](http://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)

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [August 6, 2013, 9:44pm UTC](https://forum.ansible.com/t/ini-file-without-sections/13264/2 "2013-08-06T21:44:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Ritesh\_Khadgaray](https://avatars.discourse-cdn.com/v4/letter/r/eb8c5e/32.png) [@Ritesh\_Khadgaray](https://forum.ansible.com/u/Ritesh_Khadgaray)\
**Post date:** [June 24, 2015, 3:52pm UTC](https://forum.ansible.com/t/ini-file-without-sections/13264/3 "2015-06-24T15:52:14Z")

</div>

Hi

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

Thanks  
-ritz
