# BUG: "unable to convert str to int" but 'str' is int ?

**URL:** <https://forum.ansible.com/t/bug-unable-to-convert-str-to-int-but-str-is-int/34576>\
**Category:** Ansible Project\
**Created:** [February 5, 2021, 4:25pm UTC](https://forum.ansible.com/t/bug-unable-to-convert-str-to-int-but-str-is-int/34576 "2021-02-05T16:25:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Axel\_Rau](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@Axel\_Rau](https://forum.ansible.com/u/Axel_Rau)\
**Post date:** [February 5, 2021, 4:25pm UTC](https://forum.ansible.com/t/bug-unable-to-convert-str-to-int-but-str-is-int/34576/1 "2021-02-05T16:25:54Z")

</div>

Hi all,

this role:  
- - -  
- name: Show calling args  
&nbsp;&nbsp;debug:  
&nbsp;&nbsp;&nbsp;&nbsp;var: ca

- name: Update DNS master server  
&nbsp;&nbsp;community.general.nsupdate:  
&nbsp;&nbsp;&nbsp;&nbsp;key\_name: "{{ key\_name }}"  
&nbsp;&nbsp;&nbsp;&nbsp;key\_algorithm: "{{ algorithm }}"  
&nbsp;&nbsp;&nbsp;&nbsp;key\_secret: "{{ secret }}"  
&nbsp;&nbsp;&nbsp;&nbsp;server: "{{ server }}"  
&nbsp;&nbsp;&nbsp;&nbsp;zone: ca.zone  
&nbsp;&nbsp;&nbsp;&nbsp;record: ca.owner\_name  
&nbsp;&nbsp;&nbsp;&nbsp;ttl: ca.ttl  
&nbsp;&nbsp;&nbsp;&nbsp;type: ca.type  
&nbsp;&nbsp;&nbsp;&nbsp;value: ca.RDATA  
- - -  
shows ttl arg as integer, but throws this exception:  
- - -  
TASK [Gathering Facts] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost]

TASK [Execute role lr\_nsupdate with args {'ca': {'zone': 'framail.de', 'owner\_name': 'meteo.framail.de', 'ttl': 300, 'type': 'CNAME', 'RDATA': ['meteo3.lrau.net', 'meteo4.lrau.net', 'meteo5.lrau.net']}}] \*\*\*

TASK [lr\_nsupdate : Show calling args] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost] =\> {  
&nbsp;&nbsp;&nbsp;&nbsp;"ca": {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"ca": {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"RDATA": [  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"meteo3.lrau.net",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"meteo4.lrau.net",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"meteo5.lrau.net"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;],  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"owner\_name": "meteo.framail.de",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"ttl": 300,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"type": "CNAME",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"zone": "framail.de"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
&nbsp;&nbsp;&nbsp;&nbsp;}  
}

TASK [lr\_nsupdate : Update DNS master server] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [localhost]: FAILED! =\> {"changed": false, "msg": "argument ttl is of type \<class 'str'\> and we were unable to convert to int: \<class 'str'\> cannot be converted to an int“}  
- - -  
What is wrong here?  
Module nsupdate does not contain any related code.  
Error seems to come from ansible framework.

Should I file a bug report?

Thanks, Axel

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [February 5, 2021, 4:36pm UTC](https://forum.ansible.com/t/bug-unable-to-convert-str-to-int-but-str-is-int/34576/2 "2021-02-05T16:36:15Z")

</div>

Hi,

> &nbsp;&nbsp;&nbsp;&nbsp;server: "{{ server }}"  
> &nbsp;&nbsp;&nbsp;&nbsp;zone: ca.zone  
> &nbsp;&nbsp;&nbsp;&nbsp;record: ca.owner\_name  
> &nbsp;&nbsp;&nbsp;&nbsp;ttl: ca.ttl

you are not templating the parameters, so the module sees the string  
"ca.ttl", which cannot be converted to an integer.

Cheers,  
Felix

---

<div class="post-metadata">

**Author:** ![Axel\_Rau](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@Axel\_Rau](https://forum.ansible.com/u/Axel_Rau)\
**Post date:** [February 5, 2021, 6:28pm UTC](https://forum.ansible.com/t/bug-unable-to-convert-str-to-int-but-str-is-int/34576/3 "2021-02-05T18:28:52Z")

</div>

Hi,

thanks for answering, but:

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [February 5, 2021, 8:12pm UTC](https://forum.ansible.com/t/bug-unable-to-convert-str-to-int-but-str-is-int/34576/4 "2021-02-05T20:12:30Z")

</div>

Hi,

> \> you are not templating the parameters,
> 
> How and where should I template the parameters?

templating uses `{{` and `}}` (Jinja2 templating).

So you have to write

&nbsp;&nbsp;&nbsp;option: '{{ templated expression }}'

if you want to evaluate `templated expression`, and

&nbsp;&nbsp;&nbsp;option: 'templated expression'

if you want the literal string "templated expression".

Cheers,  
Felix

---

<div class="post-metadata">

**Author:** ![Axel\_Rau](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@Axel\_Rau](https://forum.ansible.com/u/Axel_Rau)\
**Post date:** [February 6, 2021, 5:10pm UTC](https://forum.ansible.com/t/bug-unable-to-convert-str-to-int-but-str-is-int/34576/5 "2021-02-06T17:10:54Z")

</div>

Yes, I did this, but with double quotes, which failed.  
So everything runs as expected.

Thanks for your patience,  
Axel
