# Unknown error with arguments of roles

**URL:** <https://forum.ansible.com/t/unknown-error-with-arguments-of-roles/36104>\
**Category:** Ansible Project\
**Created:** [December 12, 2021, 12:51pm UTC](https://forum.ansible.com/t/unknown-error-with-arguments-of-roles/36104 "2021-12-12T12:51:37Z")\
**Posts on this page:** 6\
**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:** [December 12, 2021, 12:51pm UTC](https://forum.ansible.com/t/unknown-error-with-arguments-of-roles/36104/1 "2021-12-12T12:51:37Z")

</div>

Hi all,

I have a role lr\_nsupdate so:  
- - -  
- 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 | default(None) }}'  
&nbsp;&nbsp;&nbsp;&nbsp;record: '{{ ca.owner\_name }}'  
&nbsp;&nbsp;&nbsp;&nbsp;ttl: '{{ the\_ttl | default(3600) }}'  
&nbsp;&nbsp;&nbsp;&nbsp;type: '{{ ca.type }}'  
&nbsp;&nbsp;&nbsp;&nbsp;value: '{{ ca.RDATA }}'  
&nbsp;&nbsp;&nbsp;&nbsp;state: '{{ ca.state | default(present) }}‘  
- - -  
When I call it so in another role:  
- - -  
- name: 'Delete CNAME db.lrau.net'  
&nbsp;&nbsp;include\_role:  
&nbsp;&nbsp;&nbsp;&nbsp;name: lr\_nsupdate  
&nbsp;&nbsp;vars:  
&nbsp;&nbsp;&nbsp;&nbsp;ca:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ca.owner\_name: 'db.lrau.net.'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ca.state: 'absent'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ca.type: ‚CNAME‘  
- - -  
I get:  
- - -  
ok: [dbo5] =\> {  
&nbsp;&nbsp;&nbsp;&nbsp;"ca": {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"ca.owner\_name": "db.lrau.net.",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"ca.state": "absent",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"ca.type": "CNAME"  
&nbsp;&nbsp;&nbsp;&nbsp;}  
}

TASK [lr\_nsupdate : Update DNS master server] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [dbo5]: FAILED! =\> {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'owner\_name'\n\nThe error appears to be in '/usr/local/etc/ansible/roles/lr\_nsupdate/tasks/main.yaml': line 31, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Update DNS master server\n ^ here\n“}  
- - -

Any help welcome,  
Axel

---

<div class="post-metadata">

**Author:** ![Jorge\_Rua1](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@Jorge\_Rua1](https://forum.ansible.com/u/Jorge_Rua1)\
**Post date:** [December 12, 2021, 12:58pm UTC](https://forum.ansible.com/t/unknown-error-with-arguments-of-roles/36104/2 "2021-12-12T12:58:11Z")

</div>

You either change it to ca.ca.owner\_name or remove the second ‘ca’ for each dict member.

---

<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:** [December 12, 2021, 4:37pm UTC](https://forum.ansible.com/t/unknown-error-with-arguments-of-roles/36104/3 "2021-12-12T16:37:35Z")

</div>

Naturally of course, (-;

Thanks, Axel

---

<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:** [December 12, 2021, 6:29pm UTC](https://forum.ansible.com/t/unknown-error-with-arguments-of-roles/36104/4 "2021-12-12T18:29:55Z")

</div>

After fixing the argument issue, I’m stuck with this:

I have a role lr\_nsupdate so:  
- - -

- 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 | default(None) }}'  
&nbsp;&nbsp;&nbsp;&nbsp;record: '{{ ca.owner\_name }}'  
&nbsp;&nbsp;&nbsp;&nbsp;ttl: '{{ the\_ttl | default(3600) }}'  
&nbsp;&nbsp;&nbsp;&nbsp;type: '{{ ca.type }}'  
&nbsp;&nbsp;&nbsp;&nbsp;value: '{{ ca.RDATA | default(None) }}'  
&nbsp;&nbsp;&nbsp;&nbsp;state: "{{ ca.state | default('present') }}"  
&nbsp;&nbsp;delegate\_to: localhost  
- - -  
When I call it so in another role:  
- - -  
- name: 'Delete CNAME db.lrau.net'  
&nbsp;&nbsp;include\_role:  
&nbsp;&nbsp;&nbsp;&nbsp;name: lr\_nsupdate  
&nbsp;&nbsp;vars:  
&nbsp;&nbsp;&nbsp;&nbsp;ca:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;owner\_name: 'db.lrau.net.'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;state: 'absent'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type: ‚CNAME‘  
- - -  
I get:  
- - -  
TASK [lr\_nsupdate : Show calling args] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [dbo5] =\> {  
&nbsp;&nbsp;&nbsp;&nbsp;"ca": {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"owner\_name": "db.lrau.net.",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"state": "absent",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"type": "CNAME"  
&nbsp;&nbsp;&nbsp;&nbsp;}  
}

TASK [lr\_nsupdate : Update DNS master server] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: IndexError: string index out of range  
fatal: [dbo5 -\> localhost]: FAILED! =\> {"changed": false, "module\_stderr": "Shared connection to localhost closed.\r\n", "module\_stdout": "Traceback (most recent call last):\r\n File \"/root/.ansible/tmp/ansible-tmp-1639333586.086785-18489-58263131450333/AnsiballZ\_nsupdate.py\", line 100, in \<module\>\r\n \_ansiballz\_main()\r\n File \"/root/.ansible/tmp/ansible-tmp-1639333586.086785-18489-58263131450333/AnsiballZ\_nsupdate.py\", line 92, in \_ansiballz\_main\r\n invoke\_module(zipped\_mod, temp\_path, ANSIBALLZ\_PARAMS)\r\n File \"/root/.ansible/tmp/ansible-tmp-1639333586.086785-18489-58263131450333/AnsiballZ\_nsupdate.py\", line 41, in invoke\_module\r\n run\_name='\_\_main\_\_', alter\_sys=True)\r\n File \"/usr/local/lib/python3.7/runpy.py\", line 205, in run\_module\r\n return \_run\_module\_code(code, init\_globals, run\_name, mod\_spec)\r\n File \"/usr/local/lib/python3.7/runpy.py\", line 96, in \_run\_module\_code\r\n mod\_name, mod\_spec, pkg\_name, script\_name)\r\n File \"/usr/local/lib/python3.7/runpy.py\", line 85, in \_run\_code\r\n exec(code, run\_globals)\r\n File \"/tmp/ansible\_community.general.nsupdate\_payload\_3364ymle/ansible\_community.general.nsupdate\_payload.zip/ansible\_collections/community/general/plugins/modules/nsupdate.py\", line 483, in \<module\>\r\n File \"/tmp/ansible\_community.general.nsupdate\_payload\_3364ymle/ansible\_community.general.nsupdate\_payload.zip/ansible\_collections/community/general/plugins/modules/nsupdate.py\", line 461, in main\r\n File \"/tmp/ansible\_community.general.nsupdate\_payload\_3364ymle/ansible\_community.general.nsupdate\_payload.zip/ansible\_collections/community/general/plugins/modules/nsupdate.py\", line 233, in \_\_init\_\_\r\nIndexError: string index out of range\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

Is this a bug in the nsupdate module?

Thanks, Axel

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [December 13, 2021, 12:29pm UTC](https://forum.ansible.com/t/unknown-error-with-arguments-of-roles/36104/5 "2021-12-13T12:29:26Z")

</div>

> ```auto
> - name: Update DNS master server
> community.general.nsupdate:
> key_name: '{{ key_name }}'
> key_algorithm: '{{ algorithm }}'
> key_secret: '{{ secret }}'
> server: '{{ server }}'
> zone: '{{ ca.zone | default(None) }}'
> record: '{{ ca.owner_name }}'
> ttl: '{{ the_ttl | default(3600) }}'
> type: '{{ ca.type }}'
> value: '{{ ca.RDATA | default(None) }}'
> state: "{{ ca.state | default('present') }}"
> delegate_to: localhost
> 
> ```

Those `default(None)` should probably be `default(omit)`.

> ```auto
> Is this a bug in the nsupdate module?
> 
> ```

I expect it is, or at least it could be handled better. But my guess is it’s being triggered by your use of `None` instead of `omit`.

​

---

<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:** [December 13, 2021, 4:21pm UTC](https://forum.ansible.com/t/unknown-error-with-arguments-of-roles/36104/6 "2021-12-13T16:21:29Z")

</div>

YES!Thanks a lot, Axel
