to_json not working on variable

207 views
Skip to first unread message

Dane Lipscombe

unread,
Dec 20, 2014, 4:42:08 AM12/20/14
to ansible...@googlegroups.com
When running ansible v1.8.2, in the below playbook, to_json fails to handle a basic variable

- name: a play that runs entirely on the ansible host
  hosts: localhost
  vars:
     users:
       - bob
       - joe
  tasks:
    # no problem
    - debug: msg="{{users|to_yaml}}"
    # ERROR: an unexpected type error occurred. Error was Undefined is not JSON serializable
    - debug: msg="{{users|to_json}}"


Dane Lipscombe

unread,
Dec 23, 2014, 12:09:44 AM12/23/14
to ansible...@googlegroups.com
Could somebody please verify weather or not its just my problem? 

Brian Coca

unread,
Dec 23, 2014, 7:44:24 AM12/23/14
to ansible...@googlegroups.com
I can confirm this, even threw in:
- debug: var=users
which works fine but still error out on your last task


--
Brian Coca

Brian Coca

unread,
Dec 23, 2014, 7:50:34 AM12/23/14
to ansible...@googlegroups.com
very weird, the following works:

- debug: msg="{{users|default('la')|to_json}}"

--
Brian Coca
Reply all
Reply to author
Forward
0 new messages