zaki_lknr.esxissh.esxissh_guest (1.1.0) — module

Manages virtual machines in ESXi with enable SSH

Authors: zaki (@zaki-lknr)

Install collection

Install with ansible-galaxy collection install zaki_lknr.esxissh:==1.1.0


Add to requirements.yml

  collections:
    - name: zaki_lknr.esxissh
      version: 1.1.0

Description

This module can be used to create new virtual machines, remove a virtual machine.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  - name: create a new virtual machine
    esxissh_guest:
      esxiaddress: '{{ esxiaddr }}'
      esxiusername: '{{ esxiuser }}'
      esxipassword: '{{ esxipass }}'
      name: mv-virtual-machine
      guest_id: centos7-64
      datastore: datastore1
      hardware:
        memory_mb: 4096
        num_cpus: 2
      networks:
        - name: VM Network
          device_type: vmxnet3
        - name: private-network-1
          device_type: vmxnet3
      disk:
        - size_gb: 60
          type: thin
        - size_gb: 20
          type: eagerzeroedthick
      cdrom:
        - type: iso
          iso_path: nfsserv/path/to/iso/CentOS-7-x86_64-Minimal-1908.iso
        - type: iso
          iso_path: nfsserv/path/to/iso/CentOS-8.2.2004-x86_64-minimal.iso
      state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  - name: remove a virtual machine
    esxissh_guest:
      esxiaddress: '{{ esxiaddr }}'
      esxiusername: '{{ esxiuser }}'
      esxipassword: '{{ esxipass }}'
      name: mv-virtual-machine
      guest_id: centos7-64
      datastore: datastore1
      state: absent

Inputs

    
disk:
    description: A list of disks to add.
    elements: dict
    suboptions:
      size_gb:
        description: Disk storage size in gb.
        type: int
      type:
        description: Type of disk.
        type: str
    type: list

name:
    description:
    - name of the virtual machine to work with.
    type: str

cdrom:
    description: A list of CD-ROM configurations for the virtual machine
    elements: dict
    suboptions:
      iso_path:
        description: The datastore path to the ISO file to use
        type: str
      type:
        description: The type of CD-ROM.
        type: str
    type: list

state:
    description: Set the state of the virtual machine.
    elements: str

guest_id:
    description:
    - Set the guest ID.
    type: str

hardware:
    description:
    - Manage virtual machine's hardware attributes.
    suboptions:
      memory_mb:
        description: Amount of memory in MB.
        type: int
      num_cpus:
        description: Number of CPUs.
        type: int
    type: dict

networks:
    description: A list of networks configurations.
    elements: dict
    suboptions:
      device_type:
        description: Virtual network device.
        type: str
      name:
        description: Name of tye portgroup or distributed virtual portgroup for this interface.
        type: str
    type: list

datastore:
    description:
    - Specify datastore or datastore cluster to provision virtual machine.
    type: str

esxiaddress:
    description:
    - The hostname or IP address of SSH on ESXi server
    type: str

esxipassword:
    description:
    - The password of SSH on ESXi server
    type: str

esxiusername:
    description:
    - The username of SSH on ESXi server
    type: str