My problem is that when I look at thing['inty_var'] in the module it's a 
string. that is : 

  - name: hard coded thingy
    parametered_module.py:
      thingy:
        stringy_var: 'asdf'
        inty_var: 3
        floaty_var: 123.21
 
Is correctly interpreted by parametered_module as an int. But when I do 
this: 

  - name: thingy with vars
    parametered_module.py:
      thingy:
        stringy_var: "{{ item['stringy'] }}"
        inty_var: "{{ item['inty'] }}"
        floaty_var: "{{ item['floaty'] }}"
    with_items:
    - {'stringy': 'asdf', 'inty': 3, 'floaty': 123.21}

It sees thingy['inty_var'] as '3' and the module assumes it's a string. Is 
there a way to force inty_var to an int within ansible? 
I also tried: inty_var: "{{ item['inty'] | int }}" but that is still a 
string by the time it gets to parametered_module

Thanks for your help!



On Sunday, August 24, 2014 7:32:44 AM UTC-7, Michael DeHaan wrote:
>
> Quick note - modules shouldn't end in ".py", either when saved or called.
>
> But what you have is fine, you can also do.
>
>   - name: thingy with vars
>     parametered_module.py:
>       thingy:
>         stringy_var: "{{ item.stringy }}"
>         inty_var: "{{ item.inty }}"
>         floaty_var: "{{ item.floaty }}"
>     with_items:
>     - {'stringy': 'asdf', 'inty': 3, 'floaty': 123.21}
>
> You may also wish to do:
>
> - name: thingy with vars
>   parameterized_module:
>      thingy: "{{ item }}"
>   with_items:
>      - ...
>
> And just name your hash variables stringy_var vs stringy, etc.
>
> You can also pass variables into with_items, and define your hash 
> elsewhere like:
>
> with_items: my_items
>
>
>
>
>
> On Sun, Aug 24, 2014 at 1:24 AM, Ayelet Goldin <[email protected] 
> <javascript:>> wrote:
>
>> I'm trying to figure out how to pass a non-string variable to a module
>>
>> https://gist.github.com/uncreative/adfe926267d0ee5b3de3
>>
>> Has anyone figured it out?
>>
>> turns inty_var and floaty_var within parametered module into strings:
>>
>>   - name: thingy with vars
>>     parametered_module.py:
>>       thingy:
>>         stringy_var: "{{ item['stringy'] }}"
>>         inty_var: "{{ item['inty'] }}"
>>         floaty_var: "{{ item['floaty'] }}"
>>     with_items:
>>     - {'stringy': 'asdf', 'inty': 3, 'floaty': 123.21}
>>
>> Thanks for your help!
>>
>>  -- 
>> 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] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/913ead1a-e6e7-4bde-95b4-c9279ac7abfa%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/913ead1a-e6e7-4bde-95b4-c9279ac7abfa%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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/48c2a08a-81af-4cf9-acd4-2ad6121fbd97%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to