yaml structures passed to roles that to_json cannot use integers

77 views
Skip to first unread message

Barry Kaplan

unread,
Jun 1, 2015, 12:30:54 PM6/1/15
to ansible...@googlegroups.com
I just got hit with https://github.com/ansible/ansible/issues/9362, where in the following 'instances' is a string when the role uses to_json to pass the data to marathon:

  vars:
    vi_instances
: "{{instances | default(2)}}"



 roles
:
   
- role: marathon_app
      marathon_app
:
        id
: /svc/auth
        cpus
: 0.5
        mem
: 64.0
        instances
: "{{vi_instances | int}}"


Does anybody know a workaround to this?

Barry Kaplan

unread,
Jun 22, 2015, 1:58:43 AM6/22/15
to ansible...@googlegroups.com
I'm still hitting a wall on this. Any ideas anybody?

Brian Coca

unread,
Jun 25, 2015, 11:39:47 PM6/25/15
to ansible...@googlegroups.com
A fix for this was merged to current devel, I'm not sure we can
backport it to older versions as the templating code involved was very
convoluted (much simpler in new version).



--
Brian Coca

David Birdsong

unread,
Jul 10, 2015, 9:33:55 AM7/10/15
to ansible...@googlegroups.com
any news on this front?

i'm trying to share data directly between ansible and consul by inheriting data from upper level variables files and i can't get integers to render to json as integers.




--
Brian Coca

Barry Kaplan

unread,
Jul 10, 2015, 10:24:56 PM7/10/15
to ansible...@googlegroups.com
I have to say this is in my top 5 biggest ansible yak shavings. So many times I just need to pass configuration directly to a role which would to_json or to_yaml it. But I cannot because of this bug. Hence I need to parse out every little variable all the way down the structure ensuring that ints or floats get converted.

Something that would be simple and elegant turns into a turd.

Brian Coca

unread,
Jul 10, 2015, 10:27:52 PM7/10/15
to ansible...@googlegroups.com
Sorry to hear,

We hope to release next month, hopefully that will fix this issue.
Variable handling was one major headache of the old codebase, part of
the reason we rewrote the core.


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