# Passing long values to Ansible variable file (all.yml) without quotes

**URL:** <https://forum.ansible.com/t/passing-long-values-to-ansible-variable-file-all-yml-without-quotes/25686>\
**Category:** Ansible Project\
**Created:** [October 5, 2017, 2:38pm UTC](https://forum.ansible.com/t/passing-long-values-to-ansible-variable-file-all-yml-without-quotes/25686 "2017-10-05T14:38:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rohin\_Gupta](https://avatars.discourse-cdn.com/v4/letter/r/db5fbb/32.png) [@Rohin\_Gupta](https://forum.ansible.com/u/Rohin_Gupta)\
**Post date:** [October 5, 2017, 2:38pm UTC](https://forum.ansible.com/t/passing-long-values-to-ansible-variable-file-all-yml-without-quotes/25686/1 "2017-10-05T14:38:06Z")

</div>

##### ANSIBLE VERSION

2.7.5

##### SUMMARY

I have the below list of variables defined in all.yml

abc: 3V4L-CA6S-UHJ8  
xyz: 06342107

MC\_INI\_VAR: " {{abc}} {{xyz}}"

This has been invoked in playbook using the below rule

name : Starting generation process  
become: yes  
become\_user: centos  
shell : java -jar run.jar {{MC\_INI\_VAR}}  
register: out

- debug: var=o

At the remote machine the transformed command was

java -jar run.jar 3V4L-CA6S-UHJ8 1688647

If I just change the variable in all.yml to

abc: 3V4L-CA6S-UHJ8  
xyz: “06342107”

At the remote machine the transformed command was

java -jar run.jar 3V4L-CA6S-UHJ8 06342107

My problem is that if xyz=06342108; it is sent correctly without quotes

Also, this value (in all.yml) is getting populated from another script which does not add quotes. I am reading about issues of handling long int in ansible variable and I need to understand on how can I fix this issue.

I do not wish to send this in quotes and and i have tried solutions like

MC\_INI\_VAR: " {{abc | string}} {{xyz}}" but it ain’t worked

Please suggest on how can I pass such values as string without quotes or if I can type cast those in playbook itself.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [October 5, 2017, 2:48pm UTC](https://forum.ansible.com/t/passing-long-values-to-ansible-variable-file-all-yml-without-quotes/25686/2 "2017-10-05T14:48:32Z")

</div>

Without quotes, xyz: 06342107 looks like an octal number to yaml  
(leading 0) and that is how it will be interpreted, adding the quotes  
force it to be a string.

You cannot type cast it after the fact, because conversion already  
occurred, the k=v notation doesn't do number conversion that is why  
that works directly.

---

<div class="post-metadata">

**Author:** ![Rohin\_Gupta](https://avatars.discourse-cdn.com/v4/letter/r/db5fbb/32.png) [@Rohin\_Gupta](https://forum.ansible.com/u/Rohin_Gupta)\
**Post date:** [October 5, 2017, 3:44pm UTC](https://forum.ansible.com/t/passing-long-values-to-ansible-variable-file-all-yml-without-quotes/25686/3 "2017-10-05T15:44:51Z")

</div>

Thanks Brian!

My problem is that these values are generated programatically. In such cases I have to generate these with quotes in the values. Isn’t there any other way to treat the values with leading 0’s diffferently?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [October 5, 2017, 3:48pm UTC](https://forum.ansible.com/t/passing-long-values-to-ansible-variable-file-all-yml-without-quotes/25686/4 "2017-10-05T15:48:47Z")

</div>

there is !!str yamlism to force always to interpret as strings

xyz: !!str 06342107
