Open branic opened 2 years ago
The module isn't always returning a module error. I did another test where I set the apiversion
, kind
, namespace
, and name
, but the name was not the name of an existing object and the task correctly failed, but the module did not.
fatal: [localhost]: FAILED! => {"changed": false, "error": 404, "msg": "Subscription ansible-automation-platform-operator: Failed to retrieve requested object: b'{\"kind\":\"Status\",\"apiVersion\":\"v1\",\"metadata\":{},\"status\":\"Failure\",\"message\":\"subscriptions.operators.coreos.com \\\\\"ansible-automation-platform-operator\\\\\" not found\",\"reason\":\"NotFound\",\"details\":{\"name\":\"ansible-automation-platform-operator\",\"group\":\"operators.coreos.com\",\"kind\":\"subscriptions\"},\"code\":404}\\n'", "reason": "Not Found", "status": 404}
@branic Thanks for the bug report. This problem should already be fixed on the main branch, but we will look into porting a fix to older branches.
I have the same problem. Version 2.3.2
SUMMARY
The
k8s_json_patch
module is failing with the error:AttributeError: 'K8sAnsibleMixin' object has no attribute 'fail_json'
I found issue #433 which has the same error with the
k8s_info
module which was fixed in version 2.3.0. However, I'm using version 2.3.1 of the collection.ISSUE TYPE
COMPONENT NAME
k8s_json_patch
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
The playbook is targeting
localhost
as the host and is running inside an execution environment. The target is a Red Hat OpenShift cluster.STEPS TO REPRODUCE
When the below task is run against an OpenShift cluster with the namespace created and the ansible-automation-platform operator installed it will fail (its missing setting the
apiversion
). Although there is a failure to find the object to patch due to the missingapiversion
setting the module fails with the `no attribute 'fail_json' which is unexpected.EXPECTED RESULTS
The task fails but without the module failing with the traceback. The
No matches found for {'prefix': None, 'api_version': 'v1', 'short_names': ['Subscription']}
message should be reported for the task.ACTUAL RESULTS
Module fails with a traceback.