import of the vmware_rest documentation (#72090)
Co-authored-by: Jill R <4121322+jillr@users.noreply.github.com>
This commit is contained in:
parent
1ae3683d0c
commit
c72e2ee675
82 changed files with 1442 additions and 2 deletions
|
@ -1,8 +1,8 @@
|
||||||
.. _vmware_ansible:
|
.. _vmware_ansible:
|
||||||
|
|
||||||
******************
|
************
|
||||||
VMware Guide
|
VMware Guide
|
||||||
******************
|
************
|
||||||
|
|
||||||
Welcome to the Ansible for VMware Guide!
|
Welcome to the Ansible for VMware Guide!
|
||||||
|
|
||||||
|
|
20
docs/docsite/rst/scenario_guides/guide_vmware_rest.rst
Normal file
20
docs/docsite/rst/scenario_guides/guide_vmware_rest.rst
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
.. _vmware_rest_scenarios:
|
||||||
|
|
||||||
|
****************************
|
||||||
|
VMware REST Scenarios
|
||||||
|
****************************
|
||||||
|
|
||||||
|
These scenarios teach you how to accomplish common VMware tasks using the REST API and the Ansible ``vmware.vmware_rest`` collection. To get started, please select the task you want to accomplish.
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 1
|
||||||
|
|
||||||
|
vmware_rest_scenarios/installation
|
||||||
|
vmware_rest_scenarios/authentication
|
||||||
|
vmware_rest_scenarios/collect_information
|
||||||
|
vmware_rest_scenarios/create_vm
|
||||||
|
vmware_rest_scenarios/vm_info
|
||||||
|
vmware_rest_scenarios/vm_hardware_tuning
|
||||||
|
vmware_rest_scenarios/run_a_vm
|
||||||
|
vmware_rest_scenarios/vm_tool_information
|
||||||
|
vmware_rest_scenarios/vm_tool_configuration
|
|
@ -41,3 +41,4 @@ platforms, products, and technologies. They explore particular use cases in grea
|
||||||
guide_kubernetes
|
guide_kubernetes
|
||||||
guide_vagrant
|
guide_vagrant
|
||||||
guide_vmware
|
guide_vmware
|
||||||
|
guide_vmware_rest
|
||||||
|
|
|
@ -13,3 +13,4 @@ The guides in this section cover integrating Ansible with popular tools for crea
|
||||||
guide_kubernetes
|
guide_kubernetes
|
||||||
guide_vagrant
|
guide_vagrant
|
||||||
guide_vmware
|
guide_vmware
|
||||||
|
guide_vmware_rest
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
.. _vmware_rest_authentication:
|
||||||
|
|
||||||
|
*******************************************
|
||||||
|
How to configure the vmware_rest collection
|
||||||
|
*******************************************
|
||||||
|
|
||||||
|
.. contents::
|
||||||
|
:local:
|
||||||
|
|
||||||
|
|
||||||
|
Introduction
|
||||||
|
============
|
||||||
|
|
||||||
|
The vcenter_rest modules need to be authenticated. There are two different
|
||||||
|
|
||||||
|
Environment variables
|
||||||
|
=====================
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
This solution requires that you call the modules from the local machine.
|
||||||
|
|
||||||
|
You need to export some environment variables in your shell before you call the modules.
|
||||||
|
|
||||||
|
.. code-block:: shell
|
||||||
|
|
||||||
|
$ export VMWARE_HOST=vcenter.test
|
||||||
|
$ export VMWARE_USER=myvcenter-user
|
||||||
|
$ export VMWARE_password=mypassword
|
||||||
|
$ ansible-playbook my-playbook.yaml
|
||||||
|
|
||||||
|
Module parameters
|
||||||
|
=================
|
||||||
|
|
||||||
|
All the vcenter_rest modules accept the following arguments:
|
||||||
|
|
||||||
|
- ``vcenter_host``
|
||||||
|
- ``vcenter_username``
|
||||||
|
- ``vcenter_password``
|
||||||
|
|
||||||
|
|
||||||
|
Ignore SSL certificate error
|
||||||
|
============================
|
||||||
|
|
||||||
|
It's common to run a test environment without a proper SSL certificate configuration.
|
||||||
|
|
||||||
|
To ignore the SSL error, you can use the ``vcenter_validate_certs: no`` argument or
|
||||||
|
``export VMWARE_VALIDATE_CERTS=no`` to set the environment variable.
|
|
@ -0,0 +1,109 @@
|
||||||
|
.. _vmware_rest_collect_info:
|
||||||
|
|
||||||
|
*************************************************
|
||||||
|
How to collect information about your environment
|
||||||
|
*************************************************
|
||||||
|
|
||||||
|
.. contents::
|
||||||
|
:local:
|
||||||
|
|
||||||
|
|
||||||
|
Introduction
|
||||||
|
============
|
||||||
|
|
||||||
|
This section shows you how to utilize Ansible to collect information about your environment.
|
||||||
|
This information is useful for the other tutorials.
|
||||||
|
|
||||||
|
Scenario requirements
|
||||||
|
=====================
|
||||||
|
|
||||||
|
In this scenario we've got a vCenter with an ESXi host.
|
||||||
|
|
||||||
|
Our environment is pre-initialized with the following elements:
|
||||||
|
|
||||||
|
- A datacenter called ``my_dc``
|
||||||
|
- A cluster called ``my_cluser``
|
||||||
|
- A cluster called ``my_cluser``
|
||||||
|
- An ESXi host called ``esxi1`` is in the cluster
|
||||||
|
- Two datastores on the ESXi: ``rw_datastore`` and ``ro_datastore``
|
||||||
|
- A dvswitch based guest network
|
||||||
|
|
||||||
|
Finally, we use the environment variables to authenticate ourselves as explained in :ref:`vmware_rest_authentication`.
|
||||||
|
|
||||||
|
How to collect information
|
||||||
|
==========================
|
||||||
|
|
||||||
|
In these examples, we use the ``vcenter_*_info`` module to collect information about the associated resources.
|
||||||
|
|
||||||
|
All these modules return a ``value`` key. Depending on the context, this ``value`` key will be either a list or a dictionary.
|
||||||
|
|
||||||
|
Datacenter
|
||||||
|
----------
|
||||||
|
|
||||||
|
Here we use the ``vcenter_datacenter_info`` module to list all the datacenters:
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/collect_a_list_of_the_datacenters.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
As expected, the ``value`` key of the output is a list.
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/collect_a_list_of_the_datacenters.result.json
|
||||||
|
|
||||||
|
Cluster
|
||||||
|
-------
|
||||||
|
|
||||||
|
Here we do the same with ``vcenter_cluster_info``:
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Build_a_list_of_all_the_clusters.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Build_a_list_of_all_the_clusters.result.json
|
||||||
|
|
||||||
|
And we can also fetch the details about a specific cluster, with the ``cluster`` parameter:
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Retrieve_details_about_the_first_cluster.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
And the ``value`` key of the output is this time a dictionary.
|
||||||
|
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Retrieve_details_about_the_first_cluster.result.json
|
||||||
|
|
||||||
|
Datastore
|
||||||
|
---------
|
||||||
|
|
||||||
|
Here we use ``vcenter_datastore_info`` to get a list of all the datastores:
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Retrieve_a_list_of_all_the_datastores.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Retrieve_a_list_of_all_the_datastores.result.json
|
||||||
|
|
||||||
|
Folder
|
||||||
|
------
|
||||||
|
|
||||||
|
And here again, you use the ``vcenter_folder_info`` module to retrieve a list of all the folders.
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Build_a_list_of_all_the_folders.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Build_a_list_of_all_the_folders.result.json
|
||||||
|
|
||||||
|
Most of the time, you will just want one type of folder. In this case we can use filters to reduce the amount to collect. Most of the ``_info`` modules come with similar filters.
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Build_a_list_of_all_the_folders_with_the_type_VIRTUAL_MACHINE_and_called_vm.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Build_a_list_of_all_the_folders_with_the_type_VIRTUAL_MACHINE_and_called_vm.result.json
|
|
@ -0,0 +1,39 @@
|
||||||
|
.. _vmware_rest_create_vm:
|
||||||
|
|
||||||
|
*******************************
|
||||||
|
How to create a Virtual Machine
|
||||||
|
*******************************
|
||||||
|
|
||||||
|
.. contents::
|
||||||
|
:local:
|
||||||
|
|
||||||
|
|
||||||
|
Introduction
|
||||||
|
============
|
||||||
|
|
||||||
|
This section shows you how to use Ansible to create a virtual machine.
|
||||||
|
|
||||||
|
Scenario requirements
|
||||||
|
=====================
|
||||||
|
|
||||||
|
You've already followed :ref:`vmware_rest_collect_info` and you've got the following variables defined:
|
||||||
|
|
||||||
|
- ``my_cluster_info``
|
||||||
|
- ``my_datastore``
|
||||||
|
- ``my_virtual_machine_folder``
|
||||||
|
- ``my_cluster_info``
|
||||||
|
|
||||||
|
How to create a virtual machine
|
||||||
|
===============================
|
||||||
|
|
||||||
|
In this example, we will use the ``vcenter_vm`` module to create a new guest.
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Create_a_VM.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Create_a_VM.result.json
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
``vcenter_vm`` accepts more parameters, however you may prefer to start with a simple VM and use the ``vcenter_vm_hardware`` modules to tune it up afterwards. It's easier this way to identify a potential problematical step.
|
|
@ -0,0 +1,44 @@
|
||||||
|
.. _vmware_rest_installation:
|
||||||
|
|
||||||
|
*****************************************
|
||||||
|
How to install the vmware_rest collection
|
||||||
|
*****************************************
|
||||||
|
|
||||||
|
.. contents::
|
||||||
|
:local:
|
||||||
|
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
============
|
||||||
|
|
||||||
|
The collection depends on:
|
||||||
|
|
||||||
|
- Ansible >=2.9.10 or greater
|
||||||
|
- Python 3.6 or greater
|
||||||
|
|
||||||
|
aiohttp
|
||||||
|
=======
|
||||||
|
|
||||||
|
aiohttp_ is the only dependency of the collection. You can install it with ``pip`` if you use a virtualenv to run Ansible.
|
||||||
|
|
||||||
|
.. code-block:: shell
|
||||||
|
|
||||||
|
$ pip install aiohttp
|
||||||
|
|
||||||
|
Or using an RPM.
|
||||||
|
|
||||||
|
.. code-block:: shell
|
||||||
|
|
||||||
|
$ sudo dnf install python3-aiohttp
|
||||||
|
|
||||||
|
.. _aiohttp: https://docs.aiohttp.org/en/stable/
|
||||||
|
|
||||||
|
Installation
|
||||||
|
============
|
||||||
|
|
||||||
|
The best option to install the collection is to use the ``ansible-galaxy`` command:
|
||||||
|
|
||||||
|
.. code-block:: shell
|
||||||
|
|
||||||
|
|
||||||
|
$ ansible-galaxy collection install vmware.vmware_rest
|
|
@ -0,0 +1,52 @@
|
||||||
|
.. _vmware_rest_run_a_vm:
|
||||||
|
|
||||||
|
****************************
|
||||||
|
How to run a virtual machine
|
||||||
|
****************************
|
||||||
|
|
||||||
|
.. contents::
|
||||||
|
:local:
|
||||||
|
|
||||||
|
|
||||||
|
Introduction
|
||||||
|
============
|
||||||
|
|
||||||
|
This section covers the power management of your virtual machine.
|
||||||
|
|
||||||
|
Power information
|
||||||
|
=================
|
||||||
|
|
||||||
|
Use ``vcenter_vm_power_info`` to know the power state of the VM.
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Get_guest_power_information.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Get_guest_power_information.result.json
|
||||||
|
|
||||||
|
|
||||||
|
How to start a virtual machine
|
||||||
|
==============================
|
||||||
|
|
||||||
|
Use the ``vcenter_vm_power`` module to start your VM:
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Turn_the_power_of_the_VM_on.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Turn_the_power_of_the_VM_on.result.json
|
||||||
|
|
||||||
|
How to wait until my virtual machine is ready
|
||||||
|
=============================================
|
||||||
|
|
||||||
|
If your virtual machine runs VMware Tools, you can build a loop
|
||||||
|
around the ``center_vm_tools_info`` module:
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Wait_until_my_VM_is_ready.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Wait_until_my_VM_is_ready.result.json
|
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"value": {
|
||||||
|
"start_connected": false,
|
||||||
|
"backing": {
|
||||||
|
"auto_detect": true,
|
||||||
|
"type": "HOST_DEVICE",
|
||||||
|
"host_device": ""
|
||||||
|
},
|
||||||
|
"allow_guest_control": true,
|
||||||
|
"label": "Floppy drive 1",
|
||||||
|
"state": "NOT_CONNECTED"
|
||||||
|
},
|
||||||
|
"id": "8000",
|
||||||
|
"changed": true
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
- name: Add a floppy disk drive
|
||||||
|
vcenter_vm_hardware_floppy:
|
||||||
|
vm: '{{ test_vm1_info.id }}'
|
||||||
|
allow_guest_control: true
|
||||||
|
register: my_floppy_drive
|
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
"value": {
|
||||||
|
"start_connected": false,
|
||||||
|
"pci_slot_number": 4,
|
||||||
|
"backing": {
|
||||||
|
"connection_cookie": 2145337177,
|
||||||
|
"distributed_switch_uuid": "50 33 88 3a 8c 6e f9 02-7a fd c2 c0 2c cf f2 ac",
|
||||||
|
"distributed_port": "2",
|
||||||
|
"type": "DISTRIBUTED_PORTGROUP",
|
||||||
|
"network": "dvportgroup-1649"
|
||||||
|
},
|
||||||
|
"mac_address": "00:50:56:b3:49:5c",
|
||||||
|
"mac_type": "ASSIGNED",
|
||||||
|
"allow_guest_control": false,
|
||||||
|
"wake_on_lan_enabled": false,
|
||||||
|
"label": "Network adapter 1",
|
||||||
|
"state": "NOT_CONNECTED",
|
||||||
|
"type": "VMXNET3",
|
||||||
|
"upt_compatibility_enabled": false
|
||||||
|
},
|
||||||
|
"id": "4000",
|
||||||
|
"changed": true
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
- name: Attach a VM to a dvswitch
|
||||||
|
vcenter_vm_hardware_ethernet:
|
||||||
|
vm: '{{ test_vm1_info.id }}'
|
||||||
|
pci_slot_number: 4
|
||||||
|
backing:
|
||||||
|
type: DISTRIBUTED_PORTGROUP
|
||||||
|
network: "{{ my_portgroup_info.dvs_portgroup_info.dvswitch1[0].key }}"
|
||||||
|
start_connected: false
|
||||||
|
register: _vm_hardware_ethernet_1
|
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
"value": {
|
||||||
|
"start_connected": true,
|
||||||
|
"backing": {
|
||||||
|
"iso_file": "[ro_datastore] fedora.iso",
|
||||||
|
"type": "ISO_FILE"
|
||||||
|
},
|
||||||
|
"allow_guest_control": false,
|
||||||
|
"label": "CD/DVD drive 1",
|
||||||
|
"state": "NOT_CONNECTED",
|
||||||
|
"type": "SATA",
|
||||||
|
"sata": {
|
||||||
|
"bus": 0,
|
||||||
|
"unit": 2
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": "16002",
|
||||||
|
"changed": true
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
- name: Attach an ISO image to a guest VM
|
||||||
|
vcenter_vm_hardware_cdrom:
|
||||||
|
vm: '{{ test_vm1_info.id }}'
|
||||||
|
type: SATA
|
||||||
|
sata:
|
||||||
|
bus: 0
|
||||||
|
unit: 2
|
||||||
|
start_connected: true
|
||||||
|
backing:
|
||||||
|
iso_file: '[ro_datastore] fedora.iso'
|
||||||
|
type: ISO_FILE
|
||||||
|
register: _result
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"drs_enabled": false,
|
||||||
|
"cluster": "domain-c1636",
|
||||||
|
"name": "my_cluster",
|
||||||
|
"ha_enabled": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"changed": false
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
- name: Build a list of all the clusters
|
||||||
|
vcenter_cluster_info:
|
||||||
|
register: all_the_clusters
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"folder": "group-d1",
|
||||||
|
"name": "Datacenters",
|
||||||
|
"type": "DATACENTER"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"changed": false
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
- name: Build a list of all the folders
|
||||||
|
vcenter_folder_info:
|
||||||
|
register: my_folders
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"folder": "group-v1631",
|
||||||
|
"name": "vm",
|
||||||
|
"type": "VIRTUAL_MACHINE"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"changed": false
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
- name: Build a list of all the folders with the type VIRTUAL_MACHINE and called vm
|
||||||
|
vcenter_folder_info:
|
||||||
|
filter_type: VIRTUAL_MACHINE
|
||||||
|
filter_names:
|
||||||
|
- vm
|
||||||
|
register: my_folders
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"id": null,
|
||||||
|
"changed": true
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
- name: Change vm-tools upgrade policy to MANUAL
|
||||||
|
vcenter_vm_tools:
|
||||||
|
vm: '{{ test_vm1_info.id }}'
|
||||||
|
upgrade_policy: MANUAL
|
||||||
|
register: _result
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"id": null,
|
||||||
|
"changed": true
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
- name: Change vm-tools upgrade policy to UPGRADE_AT_POWER_CYCLE
|
||||||
|
vcenter_vm_tools:
|
||||||
|
vm: '{{ test_vm1_info.id }}'
|
||||||
|
upgrade_policy: UPGRADE_AT_POWER_CYCLE
|
||||||
|
register: _result
|
|
@ -0,0 +1,77 @@
|
||||||
|
{
|
||||||
|
"value": {
|
||||||
|
"instant_clone_frozen": false,
|
||||||
|
"cdroms": [],
|
||||||
|
"memory": {
|
||||||
|
"size_MiB": 1024,
|
||||||
|
"hot_add_enabled": true
|
||||||
|
},
|
||||||
|
"disks": [
|
||||||
|
{
|
||||||
|
"value": {
|
||||||
|
"scsi": {
|
||||||
|
"bus": 0,
|
||||||
|
"unit": 0
|
||||||
|
},
|
||||||
|
"backing": {
|
||||||
|
"vmdk_file": "[local] test_vm1_8/test_vm1.vmdk",
|
||||||
|
"type": "VMDK_FILE"
|
||||||
|
},
|
||||||
|
"label": "Hard disk 1",
|
||||||
|
"type": "SCSI",
|
||||||
|
"capacity": 17179869184
|
||||||
|
},
|
||||||
|
"key": "2000"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parallel_ports": [],
|
||||||
|
"sata_adapters": [],
|
||||||
|
"cpu": {
|
||||||
|
"hot_remove_enabled": false,
|
||||||
|
"count": 1,
|
||||||
|
"hot_add_enabled": false,
|
||||||
|
"cores_per_socket": 1
|
||||||
|
},
|
||||||
|
"scsi_adapters": [
|
||||||
|
{
|
||||||
|
"value": {
|
||||||
|
"scsi": {
|
||||||
|
"bus": 0,
|
||||||
|
"unit": 7
|
||||||
|
},
|
||||||
|
"label": "SCSI controller 0",
|
||||||
|
"sharing": "NONE",
|
||||||
|
"type": "PVSCSI"
|
||||||
|
},
|
||||||
|
"key": "1000"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"power_state": "POWERED_OFF",
|
||||||
|
"floppies": [],
|
||||||
|
"identity": {
|
||||||
|
"name": "test_vm1",
|
||||||
|
"instance_uuid": "5033c296-6954-64df-faca-d001de53763d",
|
||||||
|
"bios_uuid": "42330d17-e603-d925-fa4b-18827dbc1409"
|
||||||
|
},
|
||||||
|
"nvme_adapters": [],
|
||||||
|
"name": "test_vm1",
|
||||||
|
"nics": [],
|
||||||
|
"boot": {
|
||||||
|
"delay": 0,
|
||||||
|
"retry_delay": 10000,
|
||||||
|
"enter_setup_mode": false,
|
||||||
|
"type": "BIOS",
|
||||||
|
"retry": false
|
||||||
|
},
|
||||||
|
"serial_ports": [],
|
||||||
|
"boot_devices": [],
|
||||||
|
"guest_OS": "DEBIAN_8_64",
|
||||||
|
"hardware": {
|
||||||
|
"upgrade_policy": "NEVER",
|
||||||
|
"upgrade_status": "NONE",
|
||||||
|
"version": "VMX_11"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": "vm-1650",
|
||||||
|
"changed": false
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
- name: Collect information about a specific VM
|
||||||
|
vcenter_vm_info:
|
||||||
|
vm: '{{ search_result.value[0].vm }}'
|
||||||
|
register: test_vm1_info
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"value": {
|
||||||
|
"upgrade_policy": "NEVER",
|
||||||
|
"upgrade_status": "NONE",
|
||||||
|
"version": "VMX_11"
|
||||||
|
},
|
||||||
|
"changed": false
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
- name: Collect the hardware information
|
||||||
|
vcenter_vm_hardware_info:
|
||||||
|
vm: '{{ search_result.value[0].vm }}'
|
||||||
|
register: my_vm1_hardware_info
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"value": {
|
||||||
|
"bus": 0,
|
||||||
|
"pci_slot_number": 34,
|
||||||
|
"label": "SATA controller 0",
|
||||||
|
"type": "AHCI"
|
||||||
|
},
|
||||||
|
"id": "15000",
|
||||||
|
"changed": true
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
- name: Create a SATA adapter at PCI slot 34
|
||||||
|
vcenter_vm_hardware_adapter_sata:
|
||||||
|
vm: '{{ test_vm1_info.id }}'
|
||||||
|
pci_slot_number: 34
|
||||||
|
register: _sata_adapter_result_1
|
|
@ -0,0 +1,77 @@
|
||||||
|
{
|
||||||
|
"value": {
|
||||||
|
"instant_clone_frozen": false,
|
||||||
|
"cdroms": [],
|
||||||
|
"memory": {
|
||||||
|
"size_MiB": 1024,
|
||||||
|
"hot_add_enabled": true
|
||||||
|
},
|
||||||
|
"disks": [
|
||||||
|
{
|
||||||
|
"value": {
|
||||||
|
"scsi": {
|
||||||
|
"bus": 0,
|
||||||
|
"unit": 0
|
||||||
|
},
|
||||||
|
"backing": {
|
||||||
|
"vmdk_file": "[local] test_vm1_8/test_vm1.vmdk",
|
||||||
|
"type": "VMDK_FILE"
|
||||||
|
},
|
||||||
|
"label": "Hard disk 1",
|
||||||
|
"type": "SCSI",
|
||||||
|
"capacity": 17179869184
|
||||||
|
},
|
||||||
|
"key": "2000"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parallel_ports": [],
|
||||||
|
"sata_adapters": [],
|
||||||
|
"cpu": {
|
||||||
|
"hot_remove_enabled": false,
|
||||||
|
"count": 1,
|
||||||
|
"hot_add_enabled": false,
|
||||||
|
"cores_per_socket": 1
|
||||||
|
},
|
||||||
|
"scsi_adapters": [
|
||||||
|
{
|
||||||
|
"value": {
|
||||||
|
"scsi": {
|
||||||
|
"bus": 0,
|
||||||
|
"unit": 7
|
||||||
|
},
|
||||||
|
"label": "SCSI controller 0",
|
||||||
|
"sharing": "NONE",
|
||||||
|
"type": "PVSCSI"
|
||||||
|
},
|
||||||
|
"key": "1000"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"power_state": "POWERED_OFF",
|
||||||
|
"floppies": [],
|
||||||
|
"identity": {
|
||||||
|
"name": "test_vm1",
|
||||||
|
"instance_uuid": "5033c296-6954-64df-faca-d001de53763d",
|
||||||
|
"bios_uuid": "42330d17-e603-d925-fa4b-18827dbc1409"
|
||||||
|
},
|
||||||
|
"nvme_adapters": [],
|
||||||
|
"name": "test_vm1",
|
||||||
|
"nics": [],
|
||||||
|
"boot": {
|
||||||
|
"delay": 0,
|
||||||
|
"retry_delay": 10000,
|
||||||
|
"enter_setup_mode": false,
|
||||||
|
"type": "BIOS",
|
||||||
|
"retry": false
|
||||||
|
},
|
||||||
|
"serial_ports": [],
|
||||||
|
"boot_devices": [],
|
||||||
|
"guest_OS": "DEBIAN_8_64",
|
||||||
|
"hardware": {
|
||||||
|
"upgrade_policy": "NEVER",
|
||||||
|
"upgrade_status": "NONE",
|
||||||
|
"version": "VMX_11"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": "vm-1650",
|
||||||
|
"changed": true
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
- name: Create a VM
|
||||||
|
vcenter_vm:
|
||||||
|
placement:
|
||||||
|
cluster: "{{ my_cluster_info.id }}"
|
||||||
|
datastore: "{{ my_datastore.datastore }}"
|
||||||
|
folder: "{{ my_virtual_machine_folder.folder }}"
|
||||||
|
resource_pool: "{{ my_cluster_info.value.resource_pool }}"
|
||||||
|
name: test_vm1
|
||||||
|
guest_OS: DEBIAN_8_64
|
||||||
|
hardware_version: VMX_11
|
||||||
|
memory:
|
||||||
|
hot_add_enabled: true
|
||||||
|
size_MiB: 1024
|
||||||
|
register: _result
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"value": {
|
||||||
|
"backing": {
|
||||||
|
"vmdk_file": "[local] test_vm1_8/test_vm1_1.vmdk",
|
||||||
|
"type": "VMDK_FILE"
|
||||||
|
},
|
||||||
|
"label": "Hard disk 2",
|
||||||
|
"type": "SATA",
|
||||||
|
"sata": {
|
||||||
|
"bus": 0,
|
||||||
|
"unit": 0
|
||||||
|
},
|
||||||
|
"capacity": 320000
|
||||||
|
},
|
||||||
|
"id": "16000",
|
||||||
|
"changed": true
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
- name: Create a new disk
|
||||||
|
vcenter_vm_hardware_disk:
|
||||||
|
vm: '{{ test_vm1_info.id }}'
|
||||||
|
type: SATA
|
||||||
|
new_vmdk:
|
||||||
|
capacity: 320000
|
||||||
|
register: my_new_disk
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"value": {
|
||||||
|
"hot_remove_enabled": false,
|
||||||
|
"count": 1,
|
||||||
|
"hot_add_enabled": false,
|
||||||
|
"cores_per_socket": 1
|
||||||
|
},
|
||||||
|
"id": null,
|
||||||
|
"changed": false
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
- name: Dedicate one core to the VM
|
||||||
|
vcenter_vm_hardware_cpu:
|
||||||
|
vm: '{{ test_vm1_info.id }}'
|
||||||
|
count: 1
|
||||||
|
register: _result
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"value": {
|
||||||
|
"disks": []
|
||||||
|
},
|
||||||
|
"changed": false
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
- name: Get VM storage policy
|
||||||
|
vcenter_vm_storage_policy_info:
|
||||||
|
vm: '{{ test_vm1_info.id }}'
|
||||||
|
register: _result
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"value": {
|
||||||
|
"mappings": [],
|
||||||
|
"free_space": 774766592,
|
||||||
|
"capacity": 2515173376
|
||||||
|
},
|
||||||
|
"key": "/"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"changed": false
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
- name: Get guest filesystem information
|
||||||
|
vcenter_vm_guest_localfilesystem_info:
|
||||||
|
vm: '{{ test_vm1_info.id }}'
|
||||||
|
register: _result
|
||||||
|
until:
|
||||||
|
- _result is not failed
|
||||||
|
retries: 60
|
||||||
|
delay: 5
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"value": {
|
||||||
|
"full_name": {
|
||||||
|
"args": [],
|
||||||
|
"default_message": "Red Hat Fedora (64-bit)",
|
||||||
|
"id": "vmsg.guestos.fedora64Guest.label"
|
||||||
|
},
|
||||||
|
"name": "FEDORA_64",
|
||||||
|
"ip_address": "192.168.122.242",
|
||||||
|
"family": "LINUX",
|
||||||
|
"host_name": "localhost.localdomain"
|
||||||
|
},
|
||||||
|
"changed": false
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
- name: Get guest identity information
|
||||||
|
vcenter_vm_guest_identity_info:
|
||||||
|
vm: '{{ test_vm1_info.id }}'
|
||||||
|
register: _result
|
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"mac_address": "00:50:56:b3:49:5c",
|
||||||
|
"ip": {
|
||||||
|
"ip_addresses": [
|
||||||
|
{
|
||||||
|
"ip_address": "192.168.122.242",
|
||||||
|
"prefix_length": 24,
|
||||||
|
"state": "PREFERRED"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ip_address": "fe80::b8d0:511b:897f:65a2",
|
||||||
|
"prefix_length": 64,
|
||||||
|
"state": "UNKNOWN"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"nic": "4000"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"changed": false
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
- name: Get guest network interfaces information
|
||||||
|
vcenter_vm_guest_networking_interfaces_info:
|
||||||
|
vm: '{{ test_vm1_info.id }}'
|
||||||
|
register: _result
|
|
@ -0,0 +1,31 @@
|
||||||
|
{
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"gateway_address": "192.168.122.1",
|
||||||
|
"interface_index": 0,
|
||||||
|
"prefix_length": 0,
|
||||||
|
"network": "0.0.0.0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"interface_index": 0,
|
||||||
|
"prefix_length": 24,
|
||||||
|
"network": "192.168.122.0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"interface_index": 0,
|
||||||
|
"prefix_length": 64,
|
||||||
|
"network": "fe80::"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"interface_index": 0,
|
||||||
|
"prefix_length": 128,
|
||||||
|
"network": "fe80::b8d0:511b:897f:65a2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"interface_index": 0,
|
||||||
|
"prefix_length": 8,
|
||||||
|
"network": "ff00::"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"changed": false
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
- name: Get guest network routes information
|
||||||
|
vcenter_vm_guest_networking_routes_info:
|
||||||
|
vm: '{{ test_vm1_info.id }}'
|
||||||
|
register: _result
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"value": {
|
||||||
|
"dns": {
|
||||||
|
"ip_addresses": [
|
||||||
|
"10.0.2.3"
|
||||||
|
],
|
||||||
|
"search_domains": [
|
||||||
|
"localdomain"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"dns_values": {
|
||||||
|
"domain_name": "localdomain",
|
||||||
|
"host_name": "localhost.localdomain"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"changed": false
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
- name: Get guest networking information
|
||||||
|
vcenter_vm_guest_networking_info:
|
||||||
|
vm: '{{ test_vm1_info.id }}'
|
||||||
|
register: _result
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"value": {
|
||||||
|
"state": "POWERED_ON"
|
||||||
|
},
|
||||||
|
"changed": false
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
- name: Get guest power information
|
||||||
|
vcenter_vm_power_info:
|
||||||
|
vm: '{{ test_vm1_info.id }}'
|
||||||
|
register: _result
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"id": null,
|
||||||
|
"changed": true
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
- name: Increase the memory of a VM
|
||||||
|
vcenter_vm_hardware_memory:
|
||||||
|
vm: '{{ test_vm1_info.id }}'
|
||||||
|
size_MiB: 1080
|
||||||
|
register: _result
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"scsi": {
|
||||||
|
"bus": 0,
|
||||||
|
"unit": 7
|
||||||
|
},
|
||||||
|
"label": "SCSI controller 0",
|
||||||
|
"type": "PVSCSI",
|
||||||
|
"sharing": "NONE"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"changed": false
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
- name: List the SCSI adapter of a given VM
|
||||||
|
vcenter_vm_hardware_adapter_scsi_info:
|
||||||
|
vm: '{{ test_vm1_info.id }}'
|
||||||
|
register: _result
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"value": [],
|
||||||
|
"changed": false
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
- name: List the cdrom devices on the guest
|
||||||
|
vcenter_vm_hardware_cdrom_info:
|
||||||
|
vm: '{{ test_vm1_info.id }}'
|
||||||
|
register: _result
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"memory_size_MiB": 1024,
|
||||||
|
"vm": "vm-1650",
|
||||||
|
"name": "test_vm1",
|
||||||
|
"power_state": "POWERED_OFF",
|
||||||
|
"cpu_count": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"changed": false
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
- name: Look up the VM called test_vm1 in the inventory
|
||||||
|
register: search_result
|
||||||
|
vcenter_vm_info:
|
||||||
|
filter_names:
|
||||||
|
- test_vm1
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"changed": true
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"datastore": "datastore-1644",
|
||||||
|
"name": "local",
|
||||||
|
"type": "VMFS",
|
||||||
|
"free_space": 13523484672,
|
||||||
|
"capacity": 15032385536
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"datastore": "datastore-1645",
|
||||||
|
"name": "ro_datastore",
|
||||||
|
"type": "NFS",
|
||||||
|
"free_space": 24638349312,
|
||||||
|
"capacity": 26831990784
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"datastore": "datastore-1646",
|
||||||
|
"name": "rw_datastore",
|
||||||
|
"type": "NFS",
|
||||||
|
"free_space": 24638349312,
|
||||||
|
"capacity": 26831990784
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"changed": false
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
- name: Retrieve a list of all the datastores
|
||||||
|
vcenter_datastore_info:
|
||||||
|
register: my_datastores
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"value": {
|
||||||
|
"name": "my_cluster",
|
||||||
|
"resource_pool": "resgroup-1637"
|
||||||
|
},
|
||||||
|
"id": "domain-c1636",
|
||||||
|
"changed": false
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
- name: Retrieve details about the first cluster
|
||||||
|
vcenter_cluster_info:
|
||||||
|
cluster: "{{ all_the_clusters.value[0].cluster }}"
|
||||||
|
register: my_cluster_info
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"scsi": {
|
||||||
|
"bus": 0,
|
||||||
|
"unit": 0
|
||||||
|
},
|
||||||
|
"backing": {
|
||||||
|
"vmdk_file": "[local] test_vm1_8/test_vm1.vmdk",
|
||||||
|
"type": "VMDK_FILE"
|
||||||
|
},
|
||||||
|
"label": "Hard disk 1",
|
||||||
|
"type": "SCSI",
|
||||||
|
"capacity": 17179869184
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"changed": false
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
- name: Retrieve the disk information from the VM
|
||||||
|
vcenter_vm_hardware_disk_info:
|
||||||
|
vm: '{{ test_vm1_info.id }}'
|
||||||
|
register: _result
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"value": {
|
||||||
|
"size_MiB": 1024,
|
||||||
|
"hot_add_enabled": true
|
||||||
|
},
|
||||||
|
"changed": false
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
- name: Retrieve the memory information from the VM
|
||||||
|
vcenter_vm_hardware_memory_info:
|
||||||
|
vm: '{{ test_vm1_info.id }}'
|
||||||
|
register: _result
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"id": "4000",
|
||||||
|
"changed": true
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
- name: Turn the NIC's start_connected flag on
|
||||||
|
vcenter_vm_hardware_ethernet:
|
||||||
|
nic: '{{ _vm_hardware_ethernet_1.id }}'
|
||||||
|
start_connected: true
|
||||||
|
vm: '{{ test_vm1_info.id }}'
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"changed": false
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
- name: Turn the power of the VM on
|
||||||
|
vcenter_vm_power:
|
||||||
|
state: start
|
||||||
|
vm: '{{ test_vm1_info.id }}'
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"id": null,
|
||||||
|
"changed": true
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
- name: Upgrade the VM hardware version
|
||||||
|
vcenter_vm_hardware:
|
||||||
|
upgrade_policy: AFTER_CLEAN_SHUTDOWN
|
||||||
|
upgrade_version: VMX_13
|
||||||
|
vm: '{{ test_vm1_info.id }}'
|
||||||
|
register: _result
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"value": {
|
||||||
|
"auto_update_supported": false,
|
||||||
|
"upgrade_policy": "MANUAL",
|
||||||
|
"install_attempt_count": 0,
|
||||||
|
"version_status": "UNMANAGED",
|
||||||
|
"version_number": 10346,
|
||||||
|
"run_state": "RUNNING",
|
||||||
|
"version": "10346",
|
||||||
|
"install_type": "OPEN_VM_TOOLS"
|
||||||
|
},
|
||||||
|
"changed": false
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
- name: Wait until my VM is ready
|
||||||
|
vcenter_vm_tools_info:
|
||||||
|
vm: '{{ test_vm1_info.id }}'
|
||||||
|
register: vm_tools_info
|
||||||
|
until:
|
||||||
|
- vm_tools_info is not failed
|
||||||
|
- vm_tools_info.value.run_state != "NOT_RUNNING"
|
||||||
|
retries: 60
|
||||||
|
delay: 5
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"name": "my_dc",
|
||||||
|
"datacenter": "datacenter-1630"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"changed": false
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
- name: collect a list of the datacenters
|
||||||
|
vcenter_datacenter_info:
|
||||||
|
register: my_datacenters
|
|
@ -0,0 +1,150 @@
|
||||||
|
.. _vmware_rest_vm_hardware_tuning:
|
||||||
|
|
||||||
|
*******************************
|
||||||
|
How to modify a virtual machine
|
||||||
|
*******************************
|
||||||
|
|
||||||
|
.. contents::
|
||||||
|
:local:
|
||||||
|
|
||||||
|
|
||||||
|
Introduction
|
||||||
|
============
|
||||||
|
|
||||||
|
This section shows you how to use Ansible to modify an existing virtual machine.
|
||||||
|
|
||||||
|
Scenario requirements
|
||||||
|
=====================
|
||||||
|
|
||||||
|
You've already followed :ref:`vmware_rest_create_vm` and created a VM.
|
||||||
|
|
||||||
|
How to add a CDROM drive to a virtual machine
|
||||||
|
=============================================
|
||||||
|
|
||||||
|
In this example, we use the ``vcenter_vm_hardware_*`` modules to add a new CDROM to an existing VM.
|
||||||
|
|
||||||
|
Add a new SATA adapter
|
||||||
|
______________________
|
||||||
|
|
||||||
|
First we create a new SATA adapter. We specify the ``pci_slot_number``. This way if we run the task again it won't do anything if there is already an adapter there.
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Create_a_SATA_adapter_at_PCI_slot_34.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Create_a_SATA_adapter_at_PCI_slot_34.result.json
|
||||||
|
|
||||||
|
Add a CDROM drive
|
||||||
|
_________________
|
||||||
|
|
||||||
|
Now we can create the CDROM drive:
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Attach_an_ISO_image_to_a_guest_VM.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Attach_an_ISO_image_to_a_guest_VM.result.json
|
||||||
|
|
||||||
|
|
||||||
|
.. _vmware_rest_attach_a_network:
|
||||||
|
|
||||||
|
How to attach a VM to a network
|
||||||
|
===============================
|
||||||
|
|
||||||
|
Attach a new NIC
|
||||||
|
________________
|
||||||
|
|
||||||
|
Here we attach the VM to the network (through the portgroup). We specify a ``pci_slot_number`` for the same reason.
|
||||||
|
|
||||||
|
The second task adjusts the NIC configuration.
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Attach_a_VM_to_a_dvswitch.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Attach_a_VM_to_a_dvswitch.result.json
|
||||||
|
|
||||||
|
Adjust the configuration of the NIC
|
||||||
|
___________________________________
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Turn_the_NIC's_start_connected_flag_on.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Turn_the_NIC's_start_connected_flag_on.result.json
|
||||||
|
|
||||||
|
Increase the memory of the VM
|
||||||
|
=============================
|
||||||
|
|
||||||
|
We can also adjust the amount of memory that we dedicate to our VM.
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Increase_the_memory_of_a_VM.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Increase_the_memory_of_a_VM.result.json
|
||||||
|
|
||||||
|
Upgrade the hardware version of the VM
|
||||||
|
======================================
|
||||||
|
|
||||||
|
Here we use the ``vcenter_vm_hardware`` module to upgrade the version of the hardware:
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Upgrade_the_VM_hardware_version.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Upgrade_the_VM_hardware_version.result.json
|
||||||
|
|
||||||
|
Adjust the number of CPUs of the VM
|
||||||
|
===================================
|
||||||
|
|
||||||
|
You can use ``vcenter_vm_hardware_cpu`` for that:
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Dedicate_one_core_to_the_VM.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Dedicate_one_core_to_the_VM.result.json
|
||||||
|
|
||||||
|
Remove a SATA controller
|
||||||
|
========================
|
||||||
|
|
||||||
|
In this example, we remove the SATA controller of the PCI slot 34.
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Remove_SATA_adapter_at_PCI_slot_34.result.json
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Remove_SATA_adapter_at_PCI_slot_34.result.json
|
||||||
|
|
||||||
|
Attach a floppy drive
|
||||||
|
=====================
|
||||||
|
|
||||||
|
Here we attach a floppy drive to a VM.
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Add_a_floppy_disk_drive.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Add_a_floppy_disk_drive.result.json
|
||||||
|
|
||||||
|
Attach a new disk
|
||||||
|
=================
|
||||||
|
|
||||||
|
Here we attach a tiny disk to the VM. The ``capacity`` is in bytes.
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Create_a_new_disk.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Create_a_new_disk.result.json
|
|
@ -0,0 +1,129 @@
|
||||||
|
.. _vmware_rest_vm_info:
|
||||||
|
|
||||||
|
***************************************
|
||||||
|
Retrieve information from a specific VM
|
||||||
|
***************************************
|
||||||
|
|
||||||
|
.. contents::
|
||||||
|
:local:
|
||||||
|
|
||||||
|
|
||||||
|
Introduction
|
||||||
|
============
|
||||||
|
|
||||||
|
This section shows you how to use Ansible to retrieve information about a specific virtual machine.
|
||||||
|
|
||||||
|
Scenario requirements
|
||||||
|
=====================
|
||||||
|
|
||||||
|
You've already followed :ref:`vmware_rest_create_vm` and you've got create a new VM called ``test_vm1``.
|
||||||
|
|
||||||
|
How to collect virtual machine information
|
||||||
|
==========================================
|
||||||
|
|
||||||
|
List the VM
|
||||||
|
___________
|
||||||
|
|
||||||
|
In this example, we use the ``vcenter_vm_info`` module to collect information about our new VM.
|
||||||
|
|
||||||
|
In this example, we start by asking for a list of VMs. We use a filter to limit the results to just the VM called ``test_vm1``. So we are in a list context, with one single entry in the ``value`` key.
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Look_up_the_VM_called_test_vm1_in_the_inventory.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
As expected, we get a list. And thanks to our filter, we just get one entry.
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Look_up_the_VM_called_test_vm1_in_the_inventory.result.json
|
||||||
|
|
||||||
|
Collect the details about a specific VM
|
||||||
|
_______________________________________
|
||||||
|
|
||||||
|
For the next steps, we pass the ID of the VM through the ``vm`` parameter. This allow us to collect more details about this specific VM.
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Collect_information_about_a_specific_VM.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
The result is a structure with all the details about our VM. You will note this is actually the same information that we get when we created the VM.
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Collect_information_about_a_specific_VM.result.json
|
||||||
|
|
||||||
|
|
||||||
|
Get the hardware version of a specific VM
|
||||||
|
_________________________________________
|
||||||
|
|
||||||
|
We can also use all the ``vcenter_vm_*_info`` modules to retrieve a smaller amount
|
||||||
|
of information. Here we use ``vcenter_vm_hardware_info`` to know the hardware version of
|
||||||
|
the VM.
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Collect_the_hardware_information.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Collect_the_hardware_information.result.json
|
||||||
|
|
||||||
|
List the SCSI adapter(s) of a specific VM
|
||||||
|
_________________________________________
|
||||||
|
|
||||||
|
Here for instance, we list the SCSI adapter(s) of the VM:
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/List_the_SCSI_adapter_of_a_given_VM.task.yaml
|
||||||
|
|
||||||
|
You can do the same for the SATA controllers with ``vcenter_vm_adapter_sata_info``.
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/List_the_SCSI_adapter_of_a_given_VM.result.json
|
||||||
|
|
||||||
|
List the CDROM drive(s) of a specific VM
|
||||||
|
________________________________________
|
||||||
|
|
||||||
|
And we list its CDROM drives.
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/List_the_cdrom_devices_on_the_guest.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/List_the_cdrom_devices_on_the_guest.result.json
|
||||||
|
|
||||||
|
Get the memory information of the VM
|
||||||
|
____________________________________
|
||||||
|
|
||||||
|
Here we collect the memory information of the VM:
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Retrieve_the_memory_information_from_the_VM.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Retrieve_the_memory_information_from_the_VM.result.json
|
||||||
|
|
||||||
|
Get the storage policy of the VM
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
We use the ``vcenter_vm_storage_policy_info`` module for that:
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Get_VM_storage_policy.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Get_VM_storage_policy.result.json
|
||||||
|
|
||||||
|
Get the disk information of the VM
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
We use the ``vcenter_vm_hardware_disk_info`` for this operation:
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Retrieve_the_disk_information_from_the_VM.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Retrieve_the_disk_information_from_the_VM.result.json
|
|
@ -0,0 +1,45 @@
|
||||||
|
.. _vmware_rest_vm_tool_configuration:
|
||||||
|
|
||||||
|
**************************************************************
|
||||||
|
How to configure the VMware tools of a running virtual machine
|
||||||
|
**************************************************************
|
||||||
|
|
||||||
|
.. contents::
|
||||||
|
:local:
|
||||||
|
|
||||||
|
|
||||||
|
Introduction
|
||||||
|
============
|
||||||
|
|
||||||
|
This section show you how to collection information from a running virtual machine.
|
||||||
|
|
||||||
|
Scenario requirements
|
||||||
|
=====================
|
||||||
|
|
||||||
|
You've already followed :ref:`vmware_rest_run_a_vm` and your virtual machine runs VMware Tools.
|
||||||
|
|
||||||
|
How to change the upgrade policy
|
||||||
|
================================
|
||||||
|
|
||||||
|
Change the upgrade policy to MANUAL
|
||||||
|
---------------------------------------------------
|
||||||
|
|
||||||
|
You can adjust the VMware Tools upgrade policy with the ``vcenter_vm_tools`` module.
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Change_vm-tools_upgrade_policy_to_MANUAL.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Change_vm-tools_upgrade_policy_to_MANUAL.result.json
|
||||||
|
|
||||||
|
|
||||||
|
Change the upgrade policy to UPGRADE_AT_POWER_CYCLE
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Change_vm-tools_upgrade_policy_to_UPGRADE_AT_POWER_CYCLE.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Change_vm-tools_upgrade_policy_to_UPGRADE_AT_POWER_CYCLE.result.json
|
|
@ -0,0 +1,90 @@
|
||||||
|
.. _vmware_rest_vm_tool_information:
|
||||||
|
|
||||||
|
*****************************************************
|
||||||
|
How to get information from a running virtual machine
|
||||||
|
*****************************************************
|
||||||
|
|
||||||
|
.. contents::
|
||||||
|
:local:
|
||||||
|
|
||||||
|
|
||||||
|
Introduction
|
||||||
|
============
|
||||||
|
|
||||||
|
This section shows you how to collection information from a running virtual machine.
|
||||||
|
|
||||||
|
Scenario requirements
|
||||||
|
=====================
|
||||||
|
|
||||||
|
You've already followed :ref:`vmware_rest_run_a_vm` and your virtual machine runs VMware Tools.
|
||||||
|
|
||||||
|
How to collect information
|
||||||
|
==========================
|
||||||
|
|
||||||
|
In this example, we use the ``vcenter_vm_guest_*`` module to collect information about the associated resources.
|
||||||
|
|
||||||
|
Filesystem
|
||||||
|
----------
|
||||||
|
|
||||||
|
Here we use ``vcenter_vm_guest_localfilesystem_info`` to retrieve the details
|
||||||
|
about the filesystem of the guest. In this example we also use a ``retries``
|
||||||
|
loop. The VMware Tools may take a bit of time to start and by doing so, we give
|
||||||
|
the VM a bit more time.
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Get_guest_filesystem_information.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Get_guest_filesystem_information.result.json
|
||||||
|
|
||||||
|
Guest identity
|
||||||
|
--------------
|
||||||
|
|
||||||
|
You can use ``vcenter_vm_guest_identity_info`` to get details like the OS family or the hostname of the running VM.
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Get_guest_identity_information.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Get_guest_identity_information.result.json
|
||||||
|
|
||||||
|
Network
|
||||||
|
-------
|
||||||
|
|
||||||
|
``vcenter_vm_guest_networking_info`` will return the OS network configuration.
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Get_guest_networking_information.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Get_guest_networking_information.result.json
|
||||||
|
|
||||||
|
Network interfaces
|
||||||
|
------------------
|
||||||
|
|
||||||
|
``vcenter_vm_guest_networking_interfaces_info`` will return a list of NIC configurations.
|
||||||
|
|
||||||
|
See also :ref:`vmware_rest_attach_a_network`.
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Get_guest_network_interfaces_information.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Get_guest_network_interfaces_information.result.json
|
||||||
|
|
||||||
|
Network routes
|
||||||
|
--------------
|
||||||
|
|
||||||
|
Use ``vcenter_vm_guest_networking_routes_info`` to explore the route table of your vitual machine.
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Get_guest_network_routes_information.task.yaml
|
||||||
|
|
||||||
|
Result
|
||||||
|
______
|
||||||
|
|
||||||
|
.. literalinclude:: task_outputs/Get_guest_network_routes_information.result.json
|
||||||
|
|
Loading…
Reference in a new issue