-
Notifications
You must be signed in to change notification settings - Fork 151
Description
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
RUN THIS PLAYBOOK:
- hosts: 127.0.0.1
connection: local
become: yes
vars_files:
- deploy_nsx_cluster_vars.yml
tasks:
- name: Create Cluster IP
ansible.builtin.uri:
#hostname: "{{ nsx_node1.mgmt_ip }}"
url_username: "{{ nsx_username }}"
url_password: "{{ nsx_password }}"
validate_certs: false
method: post
force_basic_auth: yes
url: "https://{{ nsx_node1.mgmt_ip }}/api/v1/cluster/api-virtual-ip?action=set_virtual_ip&ip_address={{nsx_cluster_ip}}"
- name: Cluster IP Rest
vmware.ansible_for_nsxt.nsxt_rest:
hostname: "{{ nsx_node1.mgmt_ip }}"
username: "{{ nsx_username }}"
password: "{{ nsx_password }}"
validate_certs: false
method: post
path: /api/v1/cluster/api-virtual-ip?action=set_virtual_ip&ip_address={{nsx_cluster_ip}}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