Zeros are truncated from strings. #10281

13 views
Skip to first unread message

Dylan Humphreys

unread,
Dec 13, 2019, 8:40:55 AM12/13/19
to Ansible Project
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

old
version: 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?

James Cassell

unread,
Dec 13, 2019, 8:47:55 AM12/13/19
to Ansible List

On Fri, Dec 13, 2019, at 8:40 AM, Dylan Humphreys wrote:
> 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

Stefan Hornburg (Racke)

unread,
Dec 13, 2019, 8:47:56 AM12/13/19
to ansible...@googlegroups.com
On 12/13/19 2:40 PM, Dylan Humphreys wrote:
> 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
Racke

>
> --
> 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
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/1e5b51de-4c31-4539-82ac-5e61be4acae1%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/1e5b51de-4c31-4539-82ac-5e61be4acae1%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

signature.asc

Dylan Humphreys

unread,
Dec 13, 2019, 9:33:03 AM12/13/19
to Ansible Project
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
Reply all
Reply to author
Forward
0 new messages