I figured it out!! RawConfigParser "does not support the magical interpolation behavior"
On Thu, Jun 25, 2015 at 11:11 AM, Guy Matz <[email protected]> wrote: > Ah! Narrowing it down, the problem is actually with the ConfigParser > module . . . I have a supervisor config that has the line: > environment: PATH='/usr/java/jdk1.8.0_11/bin:%(ENV_PATH)s' > > and ConfigParser chokes whenever it tries to process that line: > >>> from ConfigParser import SafeConfigParser > >>> c = SafeConfigParser() > >>> c.read('/etc/supervisor.d/sidecar-data') > ['/etc/supervisor.d/sidecar-data'] > >>> c.sections() > ['program:sidecar-data'] > >>> c.items('program:sidecar-data') > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File "/usr/lib64/python2.6/ConfigParser.py", line 578, in items > for option in options] > File "/usr/lib64/python2.6/ConfigParser.py", line 614, in _interpolate > self._interpolate_some(option, L, rawval, section, vars, 1) > File "/usr/lib64/python2.6/ConfigParser.py", line 646, in > _interpolate_some > option, section, rest, var) > ConfigParser.InterpolationMissingOptionError: Bad value substitution: > section: [program:sidecar-data] > option : environment > key : env_path > rawval : ' > > Any ideas? > Thanks again!! > > On Thu, Jun 25, 2015 at 10:11 AM, Guy Matz <[email protected]> wrote: > >> Hi! I've written a module and am bumping up against an issue when I try >> to include a percent sign in one of the parameters, e.g.: >> >> supervisor_prog: >> name: smlp-data >> user: smlp >> command: java blah-blah-blah >> environment: PATH='/usr/java/jdk1.8.0_11/bin:%(ENV_PATH)s' >> >> Notice the % sign in the environment param above . . . that's causing >> ConfigParser to choke with: >> ConfigParser.InterpolationMissingOptionError: Bad value substitution: >> section: [program:smlp-data] >> option : environment >> key : env_path >> rawval : ' >> >> I would really like to escape that in my module code . . . anyone know >> if it's possible to escape that when I bring in the param here? >> self._environment = module.params['environment'] >> >> Or do I need to escape it in my call to the module . . i tried using {% >> raw %}...{% endraw %} - which I saw somewhere else on the mailing list - >> but that failed with a syntax error. >> >> Thanks a lot, >> Guy >> >> > -- 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 [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CABnTgtWZ1vVbJqfuVLoXO2keJr5S26GAdDJLRw5Dd8-2iY9Y1Q%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
