Closed cdd2 closed 4 years ago
I also have this problem.
The tenant is successfully removed, but the task failed with this error:
File "/tmp/ansible_bigip_appsvcs_extension_payload__umrhl9c/ansible_bigip_appsvcs_extension_payload.zip/ansible/modules/network/f5/bigip_appsvcs_extension.py", line 483, in tenant_exists
TypeError: argument of type 'NoneType' is not iterable
Please try the Role that we have on galaxy. This is where we focus new features for Automation Toolchain from ansible.
ISSUE TYPE
COMPONENT NAME
bigip_appsvcs_extension
ANSIBLE VERSION
PYTHON VERSION
BIGIP VERSION
CONFIGURATION
OS / ENVIRONMENT
macOS Mojave - 10.14.4
SUMMARY
When setting the state of the bigip_appsvcs_extension to 'absent,' the module will successfully remove the tenants specified, but the task always fails and throws a Python 'TypeError: argument of type 'NoneType' is not iterable.' This error occurs even if there are no tenants to remove.
STEPS TO REPRODUCE
EXPECTED RESULTS
This should remove all tenants (if present) without error. In the event there are no tenants to remove, this should exit gracefully and indicate that no change has been made.
ADDITIONAL INFORMATION ON ERROR
I believe the problem is linked to the 'tenant_exists' function. The code flow when state is 'absent' is as follows:
The 'tenant_exists' function does a GET request to check for the tenant's existence, but if the tenant doesn't exist then (at least for the BIG IP version I'm using) it returns an empty string for the content (Postman screenshot below).
When this occurs, the 'resp.content' is the empty string, and when "_json.loads(self._content or 'null')" is called it returns None. The GET request was successful (returns a 204 response code), so the check "'statusCode' in response" is made, and here the error occurs because 'response' is 'None.'
Adding a null check at line 481 in the bigip_appsvcs_extension.py would probably solve this issue, but I don't know what side effects that would have.
(https://github.com/f5devcentral/ansible-role-f5ansible/blob/67e2dc74cf68ca9d5fb7744db37b9494b70f79ce/library/bigip_appsvcs_extension.py#L470-L483)
https://github.com/f5devcentral/ansible-role-f5ansible/blob/67e2dc74cf68ca9d5fb7744db37b9494b70f79ce/module_utils/network/f5/icontrol.py#L113-L114
Response of GET Request on a nonexistant tenant
ACTUAL RESULTS
This will remove tenants (if they exist) but because it runs the 'tenant_exists' function before and after removal, this always throws an error currently (if removal is successful). So, while this test does not explicitly delete any tenants (as I did not create any in the playbook), the same error occurs when it does delete a tenant.