When attempting to create a new interface via maas.maas.network_interface_physical, the following error is thrown but the interface is created within MaaS.
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'NoneType' object has no attribute 'to_ansible'
fatal: [localhost]: FAILED! => changed=false
module_stderr: |-
Traceback (most recent call last):
File "/home/quinnm/.ansible/tmp/ansible-tmp-1690854602.0611262-30070-168320862924394/AnsiballZ_network_interface_physical.py", line 107, in <module>
_ansiballz_main()
File "/home/quinnm/.ansible/tmp/ansible-tmp-1690854602.0611262-30070-168320862924394/AnsiballZ_network_interface_physical.py", line 99, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/home/quinnm/.ansible/tmp/ansible-tmp-1690854602.0611262-30070-168320862924394/AnsiballZ_network_interface_physical.py", line 47, in invoke_module
runpy.run_module(mod_name='ansible_collections.maas.maas.plugins.modules.network_interface_physical', init_globals=dict(_module_fqn='ansible_collections.maas.maas.plugins.modules.network_interface_physical', _modlib_path=modlib_path),
File "/usr/lib/python3.10/runpy.py", line 224, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/usr/lib/python3.10/runpy.py", line 96, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/tmp/ansible_maas.maas.network_interface_physical_payload_o0ps5ehg/ansible_maas.maas.network_interface_physical_payload.zip/ansible_collections/maas/maas/plugins/modules/network_interface_physical.py", line 259, in <module>
File "/tmp/ansible_maas.maas.network_interface_physical_payload_o0ps5ehg/ansible_maas.maas.network_interface_physical_payload.zip/ansible_collections/maas/maas/plugins/modules/network_interface_physical.py", line 252, in main
File "/tmp/ansible_maas.maas.network_interface_physical_payload_o0ps5ehg/ansible_maas.maas.network_interface_physical_payload.zip/ansible_collections/maas/maas/plugins/modules/network_interface_physical.py", line 210, in run
File "/tmp/ansible_maas.maas.network_interface_physical_payload_o0ps5ehg/ansible_maas.maas.network_interface_physical_payload.zip/ansible_collections/maas/maas/plugins/modules/network_interface_physical.py", line 154, in ensure_present
AttributeError: 'NoneType' object has no attribute 'to_ansible'
module_stdout: ''
msg: |-
MODULE FAILURE
See stdout/stderr for the exact error
rc: 1
How
Using the following task, I was attempting to create a new interface on a test system that had a status of Ready in MaaS
In my debugging (aka lots of print statements :smile: ) I've found that for whatever reason, when this tries to run
after = updated_machine_obj.find_nic_by_mac(
new_nic_obj.mac_address
).to_ansible()
The function updated_machine_obj.find_nic_by_mac() is returning None.
Initial thought was "Maybe this is happening to quick and find_nic_by_mac() is running before the API has the new Nic info recorded. After injecting some time between creation and lookup, I don't think this is the case.
I'm still poking around on this one, but so far I've not stumbled into the solution.
What
When attempting to create a new interface via
maas.maas.network_interface_physical
, the following error is thrown but the interface is created within MaaS.How
Using the following task, I was attempting to create a new interface on a test system that had a status of
Ready
in MaaSWhy
In my debugging (aka lots of print statements :smile: ) I've found that for whatever reason, when this tries to run
The function
updated_machine_obj.find_nic_by_mac()
is returningNone
.Initial thought was "Maybe this is happening to quick and
find_nic_by_mac()
is running before the API has the new Nic info recorded. After injecting some time between creation and lookup, I don't think this is the case.I'm still poking around on this one, but so far I've not stumbled into the solution.