config_template fails to parse template if it contains a comment with leading spaces
Bug #1755821 reported by
Mohammed Naser
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack-Ansible |
Fix Released
|
High
|
Jean-Philippe Evrard |
Bug Description
If you use config_template with a template which contains leading spaces in a comment before the first section, for example
"""
# foo
[DEFAULT]
foo=bar
"""
The above will fail to parse because of the spaces, however, the following should work:
"""
# foo
[DEFAULT]
foo=bar
"""
config_template should be able to gracefully handle these cases, though, it seems that the issue stems from ConfigParser not liking that behaviour.
Changed in openstack-ansible: | |
importance: | Undecided → High |
assignee: | nobody → Kevin Carter (kevin-carter) |
Changed in openstack-ansible: | |
assignee: | Kevin Carter (kevin-carter) → nobody |
Changed in openstack-ansible: | |
assignee: | nobody → Jean-Philippe Evrard (jean-philippe-evrard) |
status: | New → Confirmed |
Changed in openstack-ansible: | |
status: | Confirmed → Fix Released |
To post a comment you must log in.
In trying to address this bug we found that Pythons ConfigParser
module will not parse an input file with an indented comment line
with leading whitespace before the first section header.
We added a valid test case to `test_with_ comments. ini` config_ template
which could be loaded by the ansible-
module with minor changes, but subsequent ini lookup
tests fail due to Pythons ConfigParser.
We think allowing ansible- config_ template to parse files
with indented comment lines with leading whitespace will cause
ansible ini lookups to fail.
>>> import ConfigParser, os ConfigParser( ) readfp( open('/ tmp/test_ with_comments. ini')) python2. 7/ConfigParser. py", line 324, in readfp python2. 7/ConfigParser. py", line 512, in _read eaderError( fpname, lineno, line) MissingSectionH eaderError: File contains no section headers. with_comments. ini, line: 1
>>> config = ConfigParser.
>>> config.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/
self._read(fp, filename)
File "/usr/lib/
raise MissingSectionH
ConfigParser.
file: /tmp/test_