# Zeros are truncated from strings. #10281

**URL:** <https://forum.ansible.com/t/zeros-are-truncated-from-strings-10281/31817>\
**Category:** Ansible Project\
**Created:** [December 13, 2019, 1:40pm UTC](https://forum.ansible.com/t/zeros-are-truncated-from-strings-10281/31817 "2019-12-13T13:40:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dylan\_Humphreys](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@Dylan\_Humphreys](https://forum.ansible.com/u/Dylan_Humphreys)\
**Post date:** [December 13, 2019, 1:40pm UTC](https://forum.ansible.com/t/zeros-are-truncated-from-strings-10281/31817/1 "2019-12-13T13:40:55Z")

</div>

Im getting that bug happen to me, but Im on 2.9.2

`  
% dpkg -l ansible

Desired=Unknown/Install/Remove/Purge/Hold

---

<div class="post-metadata">

**Author:** ![cassell](https://avatars.discourse-cdn.com/v4/letter/c/ecae2f/32.png) [@cassell](https://forum.ansible.com/u/cassell)\
**Post date:** [December 13, 2019, 1:47pm UTC](https://forum.ansible.com/t/zeros-are-truncated-from-strings-10281/31817/2 "2019-12-13T13:47:18Z")

</div>

> Im getting that bug happen to me, but Im on 2.9.2
> 
> `  
> % dpkg -l ansible
> 
> Desired=Unknown/Install/Remove/Purge/Hold
> 
> \> Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
> 
> \>/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
> 
> \>\>/ Name Version Architecture Description
> 
> +++-=============================================================-===================================-===================================-================================================================================================================================
> 
> ii ansible 2.9.2-1ppa~xenial all Ansible IT Automation
> 
> `
> 
> The code in question:  
> `  
> msg: "/usr/lib/postgresql-{{ postgresqlversion }}/bin/pg\_dump -h  
> /run/postgresql/{{ postgresqlversion }} -C --clean {{ dbname }}|  
> /usr/bin/pigz \> {{ dbbackuplocation }}/{{ oldversion }}\_{{ dbname }}\_{{  
> dbbackups.matched }}.sql.gz"  
> `
> 
> In the above, oldscmversion is:
> 
> `  
> % cat vars/demo-scmversion.yml
> 
> oldversion: 19.10  
> `

You need to make it a string by quoting it; otherwise it's treated as a floating point number. This is yaml behavior.

V/r,  
James Cassell

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [December 13, 2019, 1:47pm UTC](https://forum.ansible.com/t/zeros-are-truncated-from-strings-10281/31817/3 "2019-12-13T13:47:23Z")

</div>

> Im getting that bug happen to me, but Im on 2.9.2
> 
> \>  
> %dpkg -l ansible
> 
> Desired=Unknown/Install/Remove/Purge/Hold
> 
> \>Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
> 
> \>/ Err?=(none)/Reinst-required (Status,Err:uppercase=bad)
> 
> \>\>/Name Version Architecture  
> Description
> 
> +++-=============================================================-===================================-===================================-================================================================================================================================
> 
> ii ansible 2.9.2-1ppa~xenial all  
> AnsibleIT Automation
> 
> \>
> 
> The code in question:  
> \>  
> msg:"/usr/lib/postgresql-{{ postgresqlversion }}/bin/pg\_dump -h /run/postgresql/{{ postgresqlversion }} -C --clean {{  
> dbname }}| /usr/bin/pigz \> {{ dbbackuplocation }}/{{ oldversion }}\_{{ dbname }}\_{{ dbbackups.matched }}.sql.gz"  
> \>
> 
> In the above, oldscmversion is:
> 
> \>  
> %cat vars/demo-scmversion.yml
> 
> oldversion:19.10  
> \>
> 
> However the resulting filename for the above once rendered is "19.1"  
> Ill confess to not know how to find out what version of ansible that bug was actually addressed, but given it was back  
> in 2015, I suspect the fix referred to is in the version I am using. Can anyone help / suggest a work around?

I would try to tell Ansible that I really want a string:

oldversion: '19.10'

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Dylan\_Humphreys](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@Dylan\_Humphreys](https://forum.ansible.com/u/Dylan_Humphreys)\
**Post date:** [December 13, 2019, 2:33pm UTC](https://forum.ansible.com/t/zeros-are-truncated-from-strings-10281/31817/4 "2019-12-13T14:33:03Z")

</div>

Thank you all for your assistance

`

141 - name: write the version to an variables file we can include in other plays

142 copy:  
143 dest: “vars/{{ appname }}-version.yml”  
144 content: “oldversion: ‘{{ oldversion }}’”  
145 delegate\_to: localhost  
146 when:  
147 - existingapp.stat.exists == True

`

With {{ oldversion }} in single quotes. Other things I tried including (on line 144) {{ oldversion | quote }} and {{ oldversion | string }} where in the task where Im rendering the command for the backup. e.g.

`  
/usr/lib/postgresql-{{ postgresqlversion }}/bin/pg\_dump -h /run/postgresql/{{ postgresqlversion }} -C --clean {{ dbname }}| /usr/bin/pigz \> {{ dbbackuplocation }}/{{ oldversion | string }}_{{ dbname }}_{{ dbbackups.matched }}.sql.gz

`
