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

Hi all,

this role:
- - -
- name: Show calling args
  debug:
    var: ca

- name: Update DNS master server
  community.general.nsupdate:
    key_name: "{{ key_name }}"
    key_algorithm: "{{ algorithm }}"
    key_secret: "{{ secret }}"
    server: "{{ server }}"
    zone: ca.zone
    record: ca.owner_name
    ttl: ca.ttl
    type: ca.type
    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] => {
    "ca": {
        "ca": {
            "RDATA": [
                "meteo3.lrau.net",
                "meteo4.lrau.net",
                "meteo5.lrau.net"
            ],
            "owner_name": "meteo.framail.de",
            "ttl": 300,
            "type": "CNAME",
            "zone": "framail.de"
        }
    }
}

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

Hi,

    server: "{{ server }}"
    zone: ca.zone
    record: ca.owner_name
    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

Hi,

thanks for answering, but:

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

   option: '{{ templated expression }}'

if you want to evaluate `templated expression`, and

   option: 'templated expression'

if you want the literal string "templated expression".

Cheers,
Felix

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

Thanks for your patience,
Axel