Unknown error with arguments of roles

51 views
Skip to first unread message

Axel Rau

unread,
Dec 12, 2021, 7:52:01 AM12/12/21
to Ansible Project
Hi all,

I have a role lr_nsupdate so:
- - -
- 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 | default(None) }}'
record: '{{ ca.owner_name }}'
ttl: '{{ the_ttl | default(3600) }}'
type: '{{ ca.type }}'
value: '{{ ca.RDATA }}'
state: '{{ ca.state | default(present) }}‘
- - -
When I call it so in another role:
- - -
- name: 'Delete CNAME db.lrau.net'
include_role:
name: lr_nsupdate
vars:
ca:
ca.owner_name: 'db.lrau.net.'
ca.state: 'absent'
ca.type: ‚CNAME‘
- - -
I get:
- - -
ok: [dbo5] => {
"ca": {
"ca.owner_name": "db.lrau.net.",
"ca.state": "absent",
"ca.type": "CNAME"
}
}

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
---
PGP-Key: CDE74120 ☀ computing @ chaos claudius

signature.asc

Jorge Rúa

unread,
Dec 12, 2021, 7:58:36 AM12/12/21
to ansible...@googlegroups.com
You either change it to ca.ca.owner_name or remove the second 'ca' for each dict member.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/0B03386D-4CEF-4BCA-A1AC-F6D1156BFB30%40Chaos1.DE.

Axel Rau

unread,
Dec 12, 2021, 11:37:56 AM12/12/21
to ansible...@googlegroups.com


Am 12.12.2021 um 13:58 schrieb Jorge Rúa <jruar...@gmail.com>:

You either change it to ca.ca.owner_name or remove the second 'ca' for each dict member.
Naturally of course, (-;

Thanks, Axel
signature.asc

Axel Rau

unread,
Dec 12, 2021, 1:30:19 PM12/12/21
to Ansible Project
After fixing the argument issue, I’m stuck with this:


I have a role lr_nsupdate so:
- - -

- 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 | 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
- - -
When I call it so in another role:
- - -
- name: 'Delete CNAME db.lrau.net'
include_role:
name: lr_nsupdate
vars:
ca:
owner_name: 'db.lrau.net.'
state: 'absent'
type: ‚CNAME‘
- - -
I get:
- - -
TASK [lr_nsupdate : Show calling args] *********************************************************************************************************************************************************************************************************************
ok: [dbo5] => {
"ca": {
"owner_name": "db.lrau.net.",
"state": "absent",
"type": "CNAME"
}
}

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
signature.asc

Todd Lewis

unread,
Dec 13, 2021, 7:29:39 AM12/13/21
to ansible...@googlegroups.com
- 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).

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.

Axel Rau

unread,
Dec 13, 2021, 11:21:54 AM12/13/21
to Ansible Project


Am 13.12.2021 um 13:29 schrieb Todd Lewis <uto...@gmail.com>:


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

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.

YES!
Thanks a lot, Axel
signature.asc
Reply all
Reply to author
Forward
0 new messages