VMware Workstation API remote access

I was really excited by Adam’s great Ansible Module for VMware Workstation. To use this Module from my Development Environment, VMware Workstation API remote access is necessary. You can configure the REST API service to provide HTTP access locally and HTTPS access both locally and remotely.

Configure REST API HTTPS

The VMware Workstation documentation highlights the use of a self-signed certificate. Another option is the use of a signed certificate generated with XCA. If you use a signed certificate you should use a PEM chain instead of a single certificate.

Configure REST API HTTPS - Secure Connection
Configure REST API HTTPS - Certificate Chain

In both setups (self-signed certificate or signed certificate) you need to export the certificate (chain) and the private key as a PEM file. The vmrest utility needs both files and the “public” IP as input to start the VMware Workstation API remote access.

vmrest.exe -c C:\Users\marku\Documents\mk-nb-01.lab.local.crt -k C:\Users\marku\Documents\mk-nb-01.key -i 192.168.1.149

vmrest.exe -c C:\Users\marku\Documents\mk-nb-01.lab.local-chain.pem -k C:\Users\marku\Documents\mk-nb-01.key -i 192.168.1.149
VMware Workstation API remote access

Execute Playbook with HTTPS

With the latest commits to Adam’s GitHub Repository, you are able to consume the VMware Workstation Pro API remotely via HTTPS even with self-signed certificates.

- name: VMw WS API
  hosts: localhost
  gather_facts: no
  tasks:
    - name: "Get infos"
      unix_vmware_desktop_vminfos:
        api_url: "https://192.168.1.149"
        api_port: "8697"
        validate_certs: no
        username: "admin"
        password: "Passw0rd!1"
      register: vminfos
    - name: "Output"
      debug:
          var: vminfos
VMware Workstation API - Ansible Playbook

Leave a Reply