Git Product home page Git Product logo

ansible-vmware-workstation-fusion-pro-modules's Introduction

Ansible modules interacting with VMware Workstation/Fusion Pro's REST API


Introduction: How I ended up developing a VMware Workstation/Fusion Pro Ansible module


Getting Started

Get vmrest up and running

Set up your credentials:

  • On Windows, change directories to the Workstation Pro installation folder, and run vmrest.exe -C.
  • On Unix, run vmrest -C.

Then run vmrest:

  • On Windows, change directories to the Workstation Pro installation folder, and run vmrest.exe command.
  • On Unix, run vmrest.

More informations on VMware REST API's docs: Workstation Pro | Fusion Pro

Install the modules

Install from ansible-galaxy:

ansible-galaxy collection install qsypoq.vmware_desktop

Manual installation:

Put the content of plugins/modules to ~/.ansible/plugins/modules/ or in a library folder next to your playbooks.

Informations

Info retriving

For the modules with infos retriving only purposes you must set your ansible command with verbose flag, like:

ansible-playbook -i hosts.yml playbook.yml -vvv

Native use/exploitation of returned infos is WIP.

Common variables

This 4 variables can/must to used with all the modules:

    username: "api-username"
    password: "api-password"
    api_url: "http://127.0.0.1"
    api_port: "8697"
    validate_certs: no

If you are using defaults vmrest url settings then you don't have to use api_url and api_port, as their defaults values are set to vmrest's defaults.

If you are using HTTPS you might want to use validate_certs, default is set to no.

Each time you can use target_vm you can also use target_vm_name instead, which require the display name of your VM. (The one you see on your GUI).

Documentation

Here you will found basic examples. If you need more details you can find a file named $module.py available for both windows & unix version in the modules folder.

Dynamic inventory plugin

First POC: Your VM needs to be named after VM's FQDN (myvm.mylocaldomain for example)

  • Create a file named vmware_desktop.yml with this content:
plugin: 'qsypoq.vmware_desktop.inventory'
url: 'your_api_ip'
port: 'you_api_port'
user: 'your_api_user'
password: 'your_api_password'

You can now pass it as an argument like ansible-playbook test.yml -i vmware_desktop.yml

For this first POC VM have only one hostvar: their VM ID, so you can use it in your playbook to target them with target_vm

Modules examples

This example are for windows's modules (Workstation Pro on Windows) but are the same for unix (Workstation Pro on Linux or Fusion Pro on macOS), you just need to replace win with unix.

Create your first playbook

Specify the collection qsypoq.vmware_desktop

Playbook's host should be the machine hosting the API:

- hosts: vmware-workstation-host
  gather_facts: no
  collections:
    - qsypoq.vmware_desktop
  tasks:

  - name: "List all VMs"
    win_vmware_desktop_vminfos:
      username: "api-username"
      password: "api-password"

win_vmware_desktop_vminfos

  • Returns a list of VM IDs and paths for all VMs
- name: "Get infos"
  win_vmware_desktop_vminfos:
    username: "api-username"
    password: "api-password"
  • Returns the VM setting information of a VM
- name: "Retrieve CPU & RAM from VM with ID 42"
  win_vmware_desktop_vminfos:
    target_vm: "42"
    username: "api-username"
    password: "api-password"
  • Retrieve the VM restrictions
- name: "Get restrictions"
  win_vmware_desktop_vminfos:
    target_vm_name: "Windows 10"
    restrictions: True
    username: "api-username"
    password: "api-password"
  • Retrieve specific VMX param
- name: "Get extendedConfigFile from VM ID 42"
  win_vmware_desktop_vminfos:
    target_vm: "42"
    param: "extendedConfigFile"
    username: "api-username"
    password: "api-password"

win_vmware_desktop_vmmgmt

  • Updates a VM CPU/RAM allocation
- name: "Change VM with ID 42's RAM allocation to 2048 & 2 vCPU"
  win_vmware_desktop_vmmgmt:
    target_vm: "42"
    action: update
    num_cpus: 2
    memory_mb: 2048
    username: "api-username"
    password: "api-password"
  • Clone a VM
- name: "Clone VM with ID 42 as KMS-Server-Clone "
  win_vmware_desktop_vmmgmt:
    target_vm: "42"
    action: clone
    name: "KMS-Server-Clone"
    username: "api-username"
    password: "api-password"
  • Deletes a VM
- name: "Delete VM ID 42"
  win_vmware_desktop_vmmgmt:
    target_vm: "42"
    action: delete
    username: "api-username"
    password: "api-password"
  • Register a VM
- name: "Register VM with name ansible_test2"
  win_vmware_desktop_vmmgmt:
    name: "ansible_test2"
    action: register
    vmx_path: 'C:\Users\Qsypoq\Documents\Virtual Machines\ansible_test2\svc_pfSense.vmx'
    username: "api-username"
    password: "api-password"
  • Update specific VMX param (NOT WORKING ATM)
- name: "Update displayName param"
    win_vmware_desktop_vmmgmt:
    target_vm_name: "pfsense"
    action: update
    param: displayName
    value: pfsense_OLD
    username: "api-username"
    password: "api-password"

win_vmware_desktop_adaptersmgmt

  • Return all network adapters in the VM
- name: "Return all network adapters in VM 42"
  win_vmware_desktop_adaptersmgmt:
    target_vm: "42"
    action: "list"
    user: "workstation-api-user"
    password: "api-password"
  • Updates a network adapter in the VM
- name: "Edit NIC N°1 of VM 42 to assign it a custom type targetting vmnet10"
    win_vmware_desktop_adaptersmgmt:
    target_vm: "42"
    action: "update"
    index: 1
    type: custom
    vmnet: vmnet10
    user: "workstation-api-user"
    password: "api-password"
  • Creates a network adapter in the VM
- name: "Create NIC N°1 of VM 42 and assign it a custom type targetting vmnet10"
    win_vmware_desktop_adaptersmgmt:
    target_vm: "42"
    action: "create"
    type: custom
    vmnet: vmnet10
    user: "workstation-api-user"
    password: "api-password"
  • Deletes a VM network adapter
- name: "Delete NIC N°1 of VM 42 "
    win_vmware_desktop_adaptersmgmt:
    target_vm: "42"
    action: "delete"
    index: 1
    user: "workstation-api-user"
    password: "api-password"
  • Returns the IP address of a VM

Doesn't work with VMs having multiple NICs

- name: "Return IP address of VM 42"
  win_vmware_desktop_adaptersmgmt:
    target_vm: "42"
    action: "getip"
    user: "workstation-api-user"
    password: "api-password"

win_vmware_desktop_power

  • Returns the power state of the VM
- name: "Get power state of the VM with ID 42 "
  win_vmware_desktop_power:
    target_vm: "42"
    username: "api-username"
    password: "api-password"
  • Changes the VM power state
- name: "Start VM with ID 42"
  win_vmware_desktop_power:
    target_vm: "42"
    state: "on"
    username: "api-username"
    password: "api-password"

win_vmware_desktop_foldersmgmt

  • Returns all shared folders mounted in a VM
- name: "List all shared folders mounted on VM ID 42"
  win_vmware_desktop_foldersmgmt:
    target_vm: "42"
    action: "infos"
    username "api-username"
    password: "api-password"
  • Create a shared folder mounted in a VM
- name: "Create shared folder named ODBG110 on VM ID 42"
  win_vmware_desktop_foldersmgmt:
    target_vm: "42"
    folder_name: "ODBG110"
    folder_path: C:\Users\qsypoq\Desktop\odbg110
    access: "rw"
    action: "create"
    username "api-username"
    password: "api-password"
  • Update shared folder
- name: "Update shared folder named ODBG110 with new path and access rights"
  win_vmware_desktop_foldersmgmt:
    target_vm: "42"
    folder_name: "ODBG110"
    folder_path: C:\Users\qsypoq\Desktop
    access: "r"
    action: "update"
    username "api-username"
    password: "api-password"
  • Deletes a shared folder
- name: "Delete shared folder named ODBG110 on VM ID 42"
  win_vmware_desktop_foldersmgmt:
    target_vm: "42"
    folder_name: "ODBG110"
    action: "delete"
    username "api-username"
    password: "api-password"

win_vmware_desktop_netmgmt

For this part to work you need to run vmrest with privileges.

  • Returns all virtual networks
- name: "Get infos of all the configured vmnets"
  win_vmware_desktop_netmgmt:
    action: infos
    username: "api-username"
    password: "api-password"
  • Creates a virtual network
- name: "Create a new vmnet as vmnet13, as host only"   
  win_vmware_desktop_netmgmt:
    vmnet: "vmnet13"
    type: "hostonly"
    action: create
    username: "api-username"
    password: "api-password"
  • Returns all MAC-to-IP settings for DHCP service
- name: "Return all Mac-to-IP settings from vmnet8"
  win_vmware_desktop_netmgmt:
    action: infos
    vmnet: "vmnet8"
    setting: "mactoip"
    username: "api-username"
    password: "api-password"
  • Returns all port forwardings
- name: "Return all the forwarded ports settings from vmnet8"
  win_vmware_desktop_netmgmt:
    action: infos
    vmnet: "vmnet13"
    setting "portforward"
    username: "api-username"
    password: "api-password"
  • Deletes port forwarding
- name: "Delete the forwarded 1337 tcp port from vmnet8"   
  win_vmware_desktop_netmgmt:
    vmnet: "vmnet8"
    protocol: "TCP"
    port: "1337"
    action: delete
    username: "api-username"
    password: "api-password"
  • Updates port forwarding
- name: "Update the forwarded 1337 tcp port from vmnet8 to 172.13.13.13:1111 with "itworks!" as description"
  win_vmware_desktop_netmgmt:
    vmnet: "vmnet8"
    protocol: "TCP"
    port: "1337"
    guest_ip_address: "172.13.13.13"
    guest_port: "1111"
    guest_description: "itworks!"
    action: update_pf
    username: "api-username"
    password: "api-password"
  • Updates the MAC-to-IP binding
- name: "Update the MAC 00:12:29:34:4B:56 to be assigned as 192.168.188.13 on vmnet8"
  win_vmware_desktop_netmgmt:
    vmnet: "vmnet8"
    mac_address: "00:12:29:34:4B:56"
    ip_address: "192.168.188.13"
    action: update_mti
    username: "api-username"
    password: "api-password"

🚧 Todo-List / Roadmap

Information gathering / Returned infos to user while running playbooks

  • Make information returned by requests (like VM Id or state) easily exploitable via playbook.

  • Create self explaining error info when something goes wrong instead of "Check your inputs"

Check user input/rationnal behaviour

  • Example: Would be great if we could prevent a user to disconnect the network adapter of the VM ansible is run from.

Code refractoring

  • If statements may be replaced/optimised.

ansible-vmware-workstation-fusion-pro-modules's People

Contributors

qsypoq avatar vmarkusk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ansible-vmware-workstation-fusion-pro-modules's Issues

Add last API features

New features found in API's documentation:

VM Management

Get the VM config params

    • Code
    • Doc py
    • Doc readme

Return the restrictions information of the VM

    • Code
    • Doc py
    • Doc readme

Register VM to the VM library

    • Code
    • Doc py
    • Doc readme

Update the VM config params

This part can't be used/tested yet because of a bug on API's side but it's done

    • Code
    • Doc py
    • Doc readme

Failed to connect to the host via ssh: ssh: connect to host x.y.x.a port 22: Operation timed out"

Hello,

Is the below incorrect?

Playbook:

  • hosts: my_vmware_pro
    gather_facts: no
    collections:
    • qsypoq.vmware_desktop
      tasks:

    • name: "List all VMs"
      win_vmware_desktop_vminfos:
      username: "john.smith"
      password: "password1234"
      api_url: "http://192.168.1.0.1"
      api_port: "8697"
      validate_certs: no

Inventory file:

[VMWare_Servers]
my_vmware_pro ansible_host=192.168.10.1 api-username="john.smith" api-password="password1234" api_url="http://192.168.10.1" api_port="8697"

Command:
ansible-playbook -i hosts.yml vmware_desktop.yml -vvv

[john]% ansible-playbook -i hosts.yml vmware_desktop.yml -vvv
ansible-playbook 2.10.7
config file = /etc/ansible/ansible.cfg
configured module search path = ['/Users/john/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/ansible
executable location = /Library/Frameworks/Python.framework/Versions/3.8/bin/ansible-playbook
python version = 3.8.2 (v3.8.2:7b3ab5921f, Feb 24 2020, 17:52:18) [Clang 6.0 (clang-600.0.57)]
Using /etc/ansible/ansible.cfg as config file
host_list declined parsing /Volumes/Dropbox/Ansible/VMWare/hosts.yml as it did not pass its verify_file() method
Parsed /Volumes/Dropbox/Ansible/VMWare/hosts.yml inventory source with ini plugin
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: vmware_desktop.yml ********************************************************************************************************************************************************************************************************************************************************************************************
1 plays in vmware_desktop.yml

PLAY [my_vmware_pro] ****************************************************************************************************************************************************************************************************************************************************************************************************
META: ran handlers

TASK [List all VMs] *****************************************************************************************************************************************************************************************************************************************************************************************************
task path: /Volumes/Dropbox/Ansible/VMWare/vmware_desktop.yml:8
<192.168.10.1> ESTABLISH SSH CONNECTION FOR USER: None
<192.168.10.1> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/Users/john/.ansible/cp/82c0ac9e26 192.168.10.1 '/bin/sh -c '"'"'echo ~ && sleep 0'"'"''
<192.168.10.1> (255, b'', b'ssh: connect to host 192.168.10.1 port 22: Operation timed out\r\n')
fatal: [my_vmware_pro]: UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.10.1 port 22: Operation timed out",
"unreachable": true
}

PLAY RECAP **************************************************************************************************************************************************************************************************************************************************************************************************************
my_vmware_pro : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0

Basic 'get started' info

Hi there, love the project idea.

Myself not being an Ansible expert, it would be great to have a quick doc to do some basic task.

Create inventory plugin

Idea coming from Reddit
How:

  • Call VM list from API, parse it and grab VM name and other usefull non-api-retrievable datas from VMX, generate.

Add last API features

New features found in API's documentation:

VM Management

Get the VM config params

    • Code
    • Doc py
    • Doc readme

Return the restrictions information of the VM

    • Code
    • Doc py
    • Doc readme

Register VM to the VM library

    • Code
    • Doc py
    • Doc readme

Update the VM config params

This part can't be used/tested yet because of a bug on API's side

    • Code
    • Doc py
    • Doc readme

target_vm_name not working on python 3.7

When interpreter_python is set to python3.7 the target_vm_name trick does not work :

The full traceback is:
Traceback (most recent call last):
  File "/home/qsypoq/.ansible/tmp/ansible-tmp-1597846994.942776-2808-172921044836590/AnsiballZ_unix_vmware_desktop_vmmgmt.py", line 102, in <module>
    _ansiballz_main()
  File "/home/qsypoq/.ansible/tmp/ansible-tmp-1597846994.942776-2808-172921044836590/AnsiballZ_unix_vmware_desktop_vmmgmt.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/qsypoq/.ansible/tmp/ansible-tmp-1597846994.942776-2808-172921044836590/AnsiballZ_unix_vmware_desktop_vmmgmt.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible.modules.unix_vmware_desktop_vmmgmt', init_globals=None, run_name='__main__', alter_sys=True)
  File "/usr/lib/python3.7/runpy.py", line 205, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_unix_vmware_desktop_vmmgmt_payload_a9661w92/ansible_unix_vmware_desktop_vmmgmt_payload.zip/ansible/modules/unix_vmware_desktop_vmmgmt.py", line 210, in <module>
  File "/tmp/ansible_unix_vmware_desktop_vmmgmt_payload_a9661w92/ansible_unix_vmware_desktop_vmmgmt_payload.zip/ansible/modules/unix_vmware_desktop_vmmgmt.py", line 207, in main
  File "/tmp/ansible_unix_vmware_desktop_vmmgmt_payload_a9661w92/ansible_unix_vmware_desktop_vmmgmt_payload.zip/ansible/modules/unix_vmware_desktop_vmmgmt.py", line 166, in run_module
FileNotFoundError: [Errno 2] No such file or directory: 'DHCV3BKA93JSTMAGUO1JT3L95QGPK9TA'
fatal: [vmware-workstation-linux]: FAILED! => {
    "changed": false,
    "module_stderr": "Shared connection to 172.20.20.30 closed.\r\n",
    "module_stdout": "Traceback (most recent call last):\r\n  File \"/home/qsypoq/.ansible/tmp/ansible-tmp-1597846994.942776-2808-172921044836590/AnsiballZ_unix_vmware_desktop_vmmgmt.py\", line 102, in <module>\r\n    _ansiballz_main()\r\n  File \"/home/qsypoq/.ansible/tmp/ansible-tmp-1597846994.942776-2808-172921044836590/AnsiballZ_unix_vmware_desktop_vmmgmt.py\", line 94, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/home/qsypoq/.ansible/tmp/ansible-tmp-1597846994.942776-2808-172921044836590/AnsiballZ_unix_vmware_desktop_vmmgmt.py\", line 40, in invoke_module\r\n    runpy.run_module(mod_name='ansible.modules.unix_vmware_desktop_vmmgmt', init_globals=None, run_name='__main__', alter_sys=True)\r\n  File \"/usr/lib/python3.7/runpy.py\", line 205, in run_module\r\n    return _run_module_code(code, init_globals, run_name, mod_spec)\r\n  File \"/usr/lib/python3.7/runpy.py\", line 96, in _run_module_code\r\n    mod_name, mod_spec, pkg_name, script_name)\r\n  File \"/usr/lib/python3.7/runpy.py\", line 85, in _run_code\r\n    exec(code, run_globals)\r\n  File \"/tmp/ansible_unix_vmware_desktop_vmmgmt_payload_a9661w92/ansible_unix_vmware_desktop_vmmgmt_payload.zip/ansible/modules/unix_vmware_desktop_vmmgmt.py\", line 210, in <module>\r\n  File \"/tmp/ansible_unix_vmware_desktop_vmmgmt_payload_a9661w92/ansible_unix_vmware_desktop_vmmgmt_payload.zip/ansible/modules/unix_vmware_desktop_vmmgmt.py\", line 207, in main\r\n  File \"/tmp/ansible_unix_vmware_desktop_vmmgmt_payload_a9661w92/ansible_unix_vmware_desktop_vmmgmt_payload.zip/ansible/modules/unix_vmware_desktop_vmmgmt.py\", line 166, in run_module\r\nFileNotFoundError: [Errno 2] No such file or directory: 'DHCV3BKA93JSTMAGUO1JT3L95QGPK9TA'\r\n",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

In python2 the currentvmx value is set as expected, for example /home/qsypoq/vmware/wintest/wintest.vmx but in python3 it got the target VM ID instead, in my case DHCV3BKA93JSTMAGUO1JT3L95QGPK9TA so it fails when trying to open it.

After tests it looks like when getting the informations from API the vm.values array is inverted:

  • Python2: vmx_path, vm_ID
  • Python3: vm_ID, vmx_path

Linux - VMs can't be cloned Error 409

Hi
This is my setup Arch linux:

localhost

  • runs ansible
  • runs vmware workstation

Goal:
Clone "AnTemp" VM (really long id - see below) to an new VM and give the VM a new hostname.

Problem:

  • Cloneing does not work.

When i try to use the "clone VMs" the connection suceeds but none of my VMs cloned. Instead i recive:

`
manuel@R920:~/.ansible$ansible-playbook -i hosts an_clone_vm_loadb.yml -vvv
ansible-playbook 2.10.3
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/manuel/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.8/site-packages/ansible
executable location = /usr/bin/ansible-playbook
python version = 3.8.6 (default, Sep 30 2020, 04:00:38) [GCC 10.2.0]
Using /etc/ansible/ansible.cfg as config file
host_list declined parsing /home/manuel/.ansible/hosts as it did not pass its verify_file() method
script declined parsing /home/manuel/.ansible/hosts as it did not pass its verify_file() method
auto declined parsing /home/manuel/.ansible/hosts as it did not pass its verify_file() method
Parsed /home/manuel/.ansible/hosts inventory source with ini plugin
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: an_clone_vm_loadb.yml ***************************************************************************************************************************************************************************************************************************************
1 plays in an_clone_vm_loadb.yml

PLAY [localhost] ******************************************************************************************************************************************************************************************************************************************************
META: ran handlers

TASK [Clone] **********************************************************************************************************************************************************************************************************************************************************
task path: /home/manuel/.ansible/an_clone_vm_loadb.yml:7
ESTABLISH LOCAL CONNECTION FOR USER: manuel
EXEC /bin/sh -c 'echo ~manuel && sleep 0'
EXEC /bin/sh -c '( umask 77 && mkdir -p "echo /home/manuel/.ansible/tmp"&& mkdir "echo /home/manuel/.ansible/tmp/ansible-tmp-1606252755.303682-106025-67445614140385" && echo ansible-tmp-1606252755.303682-106025-67445614140385="echo /home/manuel/.ansible/tmp/ansible-tmp-1606252755.303682-106025-67445614140385" ) && sleep 0'
Attempting python interpreter discovery
EXEC /bin/sh -c 'echo PLATFORM; uname; echo FOUND; command -v '"'"'/usr/bin/python'"'"'; command -v '"'"'python3.7'"'"'; command -v '"'"'python3.6'"'"'; command -v '"'"'python3.5'"'"'; command -v '"'"'python2.7'"'"'; command -v '"'"'python2.6'"'"'; command -v '"'"'/usr/libexec/platform-python'"'"'; command -v '"'"'/usr/bin/python3'"'"'; command -v '"'"'python'"'"'; echo ENDFOUND && sleep 0'
EXEC /bin/sh -c '/usr/bin/python && sleep 0'
Python interpreter discovery fallback (unable to get Linux distribution/version info)
Using module file /home/manuel/.ansible/collections/ansible_collections/qsypoq/vmware_desktop/plugins/modules/unix_vmware_desktop_vmmgmt.py
PUT /home/manuel/.ansible/tmp/ansible-local-1060167k_pq3u1/tmpgo0jvcm5 TO /home/manuel/.ansible/tmp/ansible-tmp-1606252755.303682-106025-67445614140385/AnsiballZ_unix_vmware_desktop_vmmgmt.py
EXEC /bin/sh -c 'chmod u+x /home/manuel/.ansible/tmp/ansible-tmp-1606252755.303682-106025-67445614140385/ /home/manuel/.ansible/tmp/ansible-tmp-1606252755.303682-106025-67445614140385/AnsiballZ_unix_vmware_desktop_vmmgmt.py && sleep 0'
EXEC /bin/sh -c '/usr/bin/python /home/manuel/.ansible/tmp/ansible-tmp-1606252755.303682-106025-67445614140385/AnsiballZ_unix_vmware_desktop_vmmgmt.py && sleep 0'
EXEC /bin/sh -c 'rm -f -r /home/manuel/.ansible/tmp/ansible-tmp-1606252755.303682-106025-67445614140385/ > /dev/null 2>&1 && sleep 0'
[WARNING]: Module did not set no_log for password
[WARNING]: Platform linux on host localhost is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change the meaning of that path. See
https://docs.ansible.com/ansible/2.10/reference_appendices/interpreter_discovery.html for more information.
fatal: [localhost]: FAILED! => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"invocation": {
"module_args": {
"action": "clone",
"api_port": "8697",
"api_url": "http://127.0.0.1",
"memory_mb": null,
"name": "An-LoadBalancer",
"num_cpus": null,
"password": "Ansible123#",
"target_vm": "P6VIGOQK5E0RBNAU61C7DQFQFKFBPLE9",
"target_vm_name": "",
"timeout": 30,
"username": "ansible",
"validate_certs": false
}
},
"msg": "HTTP Error 409: Conflict"
}

PLAY RECAP ************************************************************************************************************************************************************************************************************************************************************
localhost : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
`

my host file:

[controller]
ans-control ansible_connection=local

[local]
localhost ansible_connection=local

[loadbalancer]
lb01 ansible_user=ansible

[webserver]
app01 ansible_user=ansible
app02 ansible_user=ansible

vmrest ist running as user manuel on the machine. If i run it as root it can not be accessed by ansible i think. (I get no ouput from the list all VMs playbook)

The vmlist plaxbook works and i get my machine ids.

My playbook in question (not working).

`

  • hosts: localhost
    gather_facts: no
    collections:
    • qsypoq.vmware_desktop
      tasks:

    • name: "Clone"
      unix_vmware_desktop_vmmgmt:
      target_vm: "P6VIGOQK5E0RBNAU61C7DQFQFKFBPLE9"
      action: clone
      name: "An-LoadBalancer"
      username: "ansible"
      password: "Ansible123#"
      `

Here the target_vm should be cloneded to the new one with the name An-Load-Balancer. Can i also change the Hostname of the machine while cloning ?

Working:
`

  • hosts: localhost
    gather_facts: no
    collections:
    • qsypoq.vmware_desktop
      tasks:

    • name: "List all VMs"
      unix_vmware_desktop_vminfos:
      username: "ansible"
      password: "Ansible123#"
      `

Why does this error occur and how can i fix it ?
Thanks!

MODULE FAILURE\nSee stdout/stderr for the exact error

[john]% ansible-playbook -i hosts.yml vmware_desktop.yml -vvv -M ./modules
ansible-playbook 2.10.7
config file = /etc/ansible/ansible.cfg
configured module search path = ['/Users/john/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/ansible
executable location = /Library/Frameworks/Python.framework/Versions/3.8/bin/ansible-playbook
python version = 3.8.2 (v3.8.2:7b3ab5921f, Feb 24 2020, 17:52:18) [Clang 6.0 (clang-600.0.57)]
Using /etc/ansible/ansible.cfg as config file
host_list declined parsing /Volumes/Dropbox/Ansible/VMWare/hosts.yml as it did not pass its verify_file() method
Parsed /Volumes/Dropbox/Ansible/VMWare/hosts.yml inventory source with ini plugin
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: vmware_desktop.yml ********************************************************************************************************************************************************************************************************************************************************************************************
1 plays in vmware_desktop.yml

PLAY [my_vmware_pro] ****************************************************************************************************************************************************************************************************************************************************************************************************
META: ran handlers

TASK [List all VMs] *****************************************************************************************************************************************************************************************************************************************************************************************************
task path: /Volumes/Dropbox/Ansible/VMWare/vmware_desktop.yml:8
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: john
<127.0.0.1> EXEC /bin/sh -c 'echo ~john && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "echo /Users/john/.ansible/tmp"&& mkdir "echo /Users/john/.ansible/tmp/ansible-tmp-1624978848.1419132-5504-211548254995158" && echo ansible-tmp-1624978848.1419132-5504-211548254995158="echo /Users/john/.ansible/tmp/ansible-tmp-1624978848.1419132-5504-211548254995158" ) && sleep 0'
Using module file /Users/john/.ansible/collections/ansible_collections/qsypoq/vmware_desktop/plugins/modules/win_vmware_desktop_vminfos.py
<127.0.0.1> PUT /Users/john/.ansible/tmp/ansible-local-5499fkq0_mfh/tmp2melr67b TO /Users/john/.ansible/tmp/ansible-tmp-1624978848.1419132-5504-211548254995158/AnsiballZ_win_vmware_desktop_vminfos.py
<127.0.0.1> PUT /Users/john/.ansible/tmp/ansible-local-5499fkq0_mfh/tmpzywbxi1f TO /Users/john/.ansible/tmp/ansible-tmp-1624978848.1419132-5504-211548254995158/args
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /Users/john/.ansible/tmp/ansible-tmp-1624978848.1419132-5504-211548254995158/ /Users/john/.ansible/tmp/ansible-tmp-1624978848.1419132-5504-211548254995158/AnsiballZ_win_vmware_desktop_vminfos.py /Users/john/.ansible/tmp/ansible-tmp-1624978848.1419132-5504-211548254995158/args && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/Library/Frameworks/Python.framework/Versions/3.8/bin/python3 /Users/john/.ansible/tmp/ansible-tmp-1624978848.1419132-5504-211548254995158/AnsiballZ_win_vmware_desktop_vminfos.py /Users/john/.ansible/tmp/ansible-tmp-1624978848.1419132-5504-211548254995158/args && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /Users/john/.ansible/tmp/ansible-tmp-1624978848.1419132-5504-211548254995158/ > /dev/null 2>&1 && sleep 0'
fatal: [my_vmware_pro]: FAILED! => {
"changed": false,
"module_stderr": "",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 0
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.