Open steve-sander-chtr opened 2 years ago
Hello
I confirm the bug. I've found a workaround (but very dirty). Works on my side but I'm not using a lot of function of this ansible collection.
into
def execute(self):
if self.method == "get" or self.method == "post":
resp = self.operate_nsxt(method=self.method)
self.module.exit_json(changed=False, body=resp)
if self.method == "put" or self.method == "patch":
before_resp = self.operate_nsxt(method="get", ignore_errors=True)
if before_resp:
before_revision = before_resp["_revision"]
else:
before_revision = ""
@steve-sander-chtr Are you running NSX-T under 3.2 ? We are affected by this bug in 3.1.2. The _revision setting is available in 3.2 on affected request.
I’ll did download a newer version recently – I just pushed in with the native Ansible API module.
I’ll be able to confirm next week when my lab is available again.
Steve
From: Samuel MESGUICH @.> Reply-To: vmware/ansible-for-nsxt @.> Date: Wednesday, November 23, 2022 at 9:15 AM To: vmware/ansible-for-nsxt @.> Cc: "Sander, Steve A" @.>, Mention @.***> Subject: [EXTERNAL] Re: [vmware/ansible-for-nsxt] Rest API - Put/Patch/Post Logic Causes Failures (Issue #422)
CAUTION: The e-mail below is from an external source. Please exercise caution before opening attachments, clicking links, or following guidance.
@steve-sander-chtrhttps://github.com/steve-sander-chtr Are you running NSX-T under 3.2 ? We are affected by this bug in 3.1.2. The _revision setting is available in 3.2 on affected request.
— Reply to this email directly, view it on GitHubhttps://github.com/vmware/ansible-for-nsxt/issues/422#issuecomment-1325326060, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AYJJRTS5BL4YECD77ENQTUTWJY7KTANCNFSM5RCCXX3A. You are receiving this because you were mentioned.Message ID: @.***>
On my side, I confirm that this bug is not present in NSX-T 3.2.
So on my side, VMware should not announced that the ansible collection tagged NSX-T 3.2 IS NOT fully compatible back in 3.1
Correction : Issue PERSIST in NSX-T 3.2.
Workaround mentioned in https://github.com/vmware/ansible-for-nsxt/issues/422#issuecomment-1324718713 still work
@steve-sander-chtr : can you confirm that this code correct you issues ? https://github.com/vmware/ansible-for-nsxt/pull/461
Describe the bug
Lines in code 219 - 234 it looks like the module is attempting to determine the current version prior to issuing the requested put/post/patch operation by sending a GET to the target URL (with payload). Since not every URL supports GET ( or errors on the payload), the requested action of put/post/patch is not completed. Maybe use try logic here - so if the GET fails, then the requested action is still performed ?
Reproduction steps
Expected behavior
Both API calls should succeed:
PLAY [127.0.0.1] ***
TASK [Gathering Facts] ***** ok: [127.0.0.1]
TASK [Create Cluster IP] *** ok: [127.0.0.1]
TASK [Cluster IP Rest] ***** fatal: [127.0.0.1]: FAILED! => {"changed": false, "msg": "error_code: 405, error_message: Method is not allowed."}
PLAY RECAP ***** 127.0.0.1 : ok=2 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
The 405 error is on the preceding GET ( method not allowed ). And the post is never issued.
Additional context
Other URL which failed with REST API: POST - /policy/api/v1/aaa/role-bindings PUT - /api/v1/node/services/snmp ( GET with payload not supported ) POST - /api/v1/node/services/syslog/exporters