I have this problem: I am using the vSphere Replication API to get disk information for a specific VM that is being replicated:
- name: Get session id
ansible.builtin.uri:
url: "https://{{ api }}/api/rest/vr/v2/session/"
method: POST
user: "{{ username }}"
password: "{{ password }}"
headers:
Content-Type: "application/json"
validate_certs: no
register: api
delegate_to: localhost
- name: debug
debug:
msg: "{{ api }}"
- name: GET replications
ansible.builtin.uri:
url: "https://{{ api }}/api/rest/vr/v2/pairings/{{ pairing_id }}/replications?source_vc_guid={{ source_vc_guid }}"
method: GET
headers:
Content-Type: "application/json"
x-dr-session: "{{ api.json.session_id }}"
validate_certs: no
register: replications_all
delegate_to: localhost
- name: Get info about disks by hostname
ansible.builtin.uri:
url: "https://{{ api }}/api/rest/vr/v2/pairings/{{ pairing_id }}/replications/{{some_id}}/disks"
method: GET
headers:
Content-Type: "application/json"
x-dr-session: "{{ api.json.session_id }}"
delegate_to: localhost
- name: Logout
ansible.builtin.uri:
url: "https://{{ api }}/api/rest/vr/v2/session/}"
method: DELETE
headers:
Content-Type: "application/json"
x-dr-session: "{{ api.json.session_id }}"
body_format: json
validate_certs: no
register: logout_source_session
delegate_to: localhost
The issue is that vSphere Replication, to which I am sending the API requests, creates sessions with vCenter that are never closed. In the GUI, there are sessions with my login and the address 127.0.0.1. Every time I query the disks, new sessions are created between the replication and vCenter. The result is that the sessions linger on vCenter and multiply every time Ansible is run. So, in total, a single query for one server creates about 20-30 sessions. Does anyone know what the problem could be?