Actually, no, the above traceback does not have anything to do with the URI module.
Please make sure there's a github filed on it though as I'd like to understand the cause of it. Thanks! On Fri, Jan 24, 2014 at 1:08 PM, <[email protected]> wrote: > ansible 1.4.4 > > My confusion is that: > > msg: '{{ stash_json | to_json }}' > > works just fine, so it's not the to_json filter in and of itself that's > causing the bug. It's using it in the uri module (or maybe just the body > parameter). > > On Friday, January 24, 2014 10:29:05 AM UTC-6, Michael DeHaan wrote: > >> ansible --version ? >> >> Also not that this means it shouldn't raise an error but, this is easier: >> >> debug: var=stash_json >> >> >> >> >> On Fri, Jan 24, 2014 at 11:10 AM, <[email protected]> wrote: >> >>> So I'm able to create the dictionary, and I can convert it to JSON in a >>> debug statement, but when I try to convert it to JSON in the URI module it >>> throws an unhandled exception. What's going on here? >>> >>> --- >>> - name: testguy >>> gather_facts: no >>> sudo: no >>> hosts: local >>> >>> tasks: >>> - set_fact: >>> stash_json: { text: "some thing" } >>> - debug: >>> msg: '{{ stash_json | to_json }}' >>> - uri: > >>> url=http://www.example.com >>> method=POST >>> body='{{ stash_json | to_json }}' >>> return_content=yes >>> HEADER_Content-Type="application/json" >>> >>> >>> >>> $ ansible-playbook -i hosts test.yml >>> >>> PLAY [test] ************************************************************ >>> **** >>> >>> TASK: [set_fact ] ****************************** >>> ******************************* >>> ok: [localhost] >>> >>> TASK: [debug ] ****************************** >>> ********************************** >>> ok: [localhost] => { >>> "msg": { >>> "text": "some thing" >>> } >>> } >>> Traceback (most recent call last): >>> File "/tmp/jim/env/bin/ansible-playbook", line 269, in <module> >>> sys.exit(main(sys.argv[1:])) >>> File "/tmp/jim/env/bin/ansible-playbook", line 209, in main >>> pb.run() >>> File >>> "/tmp/jim/env/local/lib/python2.7/site-packages/ansible/playbook/__init__.py", >>> line 263, in run >>> if not self._run_play(play): >>> File >>> "/tmp/jim/env/local/lib/python2.7/site-packages/ansible/playbook/__init__.py", >>> line 592, in _run_play >>> if not self._run_task(play, task, False): >>> File >>> "/tmp/jim/env/local/lib/python2.7/site-packages/ansible/playbook/__init__.py", >>> line 357, in _run_task >>> self.callbacks.on_task_start(template(play.basedir, name, >>> task.module_vars, lookup_fatal=False, filter_fatal=False), is_handler) >>> File >>> "/tmp/jim/env/local/lib/python2.7/site-packages/ansible/utils/template.py", >>> line 319, in template >>> varname = template_from_string(basedir, varname, vars, >>> fail_on_undefined) >>> File >>> "/tmp/jim/env/local/lib/python2.7/site-packages/ansible/utils/template.py", >>> line 543, in template_from_string >>> return res >>> UnboundLocalError: local variable 'res' referenced before assignment >>> >>> -- >>> 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]. >>> >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >> >> >> >> -- >> Michael DeHaan <[email protected]> >> >> CTO, AnsibleWorks, Inc. >> http://www.ansibleworks.com/ >> >> -- > 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]. > For more options, visit https://groups.google.com/groups/opt_out. > -- Michael DeHaan <[email protected]> CTO, AnsibleWorks, Inc. http://www.ansibleworks.com/ -- 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]. For more options, visit https://groups.google.com/groups/opt_out.
