Note
This module is part of the community.general collection (version 10.7.3).
You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install community.general. You need further requirements to be able to use this module, see Requirements for details.
To use it in a playbook, specify: community.general.xenserver_guest_powerstate.
The below requirements are needed on the host that executes this module.
Parameter | Comments |
|---|---|
hostname aliases: host, pool string | The hostname or IP address of the XenServer host or XenServer pool master. If the value is not specified in the task, the value of environment variable Default: |
name aliases: name_label string | Name of the VM to manage. VMs running on XenServer do not necessarily have unique names. The module fails if multiple VMs with same name are found. In case of multiple VMs with same name, use This parameter is case sensitive. |
password aliases: pass, pwd string | The password to use for connecting to XenServer. If the value is not specified in the task, the value of environment variable |
state string | Specify the state VM should be in. If If Choices:
|
state_change_timeout integer | By default, module waits indefinitely for VM to change state or acquire an IP address if If this parameter is set to positive value, the module instead waits specified number of seconds for the state change. In case of timeout, module generates an error message. Default: |
username aliases: admin, user string | The username to use for connecting to XenServer. If the value is not specified in the task, the value of environment variable Default: |
uuid string | UUID of the VM to manage if known. This is XenServer’s unique identifier. It is required if name is not unique. |
validate_certs boolean | Allows connection when SSL certificates are not valid. Set to If the value is not specified in the task, the value of environment variable Choices:
|
wait_for_ip_address boolean | Wait until XenServer detects an IP address for the VM. This requires XenServer Tools to be preinstalled on the VM to work properly. Choices:
|
Attribute | Support | Description |
|---|---|---|
check_mode | Support: full | Can run in |
diff_mode | Support: none | Will return details on what has changed (or possibly needs changing in |
Note
pip install XenAPI on your Ansible Control Node. The library can also be found inside Citrix Hypervisor/XenServer SDK (downloadable from Citrix website). Copy the XenAPI.py file from the SDK to your Python site-packages on your Ansible Control Node to use it. Latest version of the library can also be acquired from GitHub: https://raw.githubusercontent.com/xapi-project/xen-api/master/scripts/examples/python/XenAPI/XenAPI.py.hostname, module defaults to http:// because https:// is problematic in most setups. Make sure you are accessing XenServer host in trusted environment or use https:// scheme explicitly.https:// scheme for hostname you have to either import host certificate to your OS certificate store or use validate_certs: no which requires XenAPI library from XenServer 7.2 SDK or newer and Python 2.7.9 or newer.- name: Power on VM
community.general.xenserver_guest_powerstate:
hostname: "{{ xenserver_hostname }}"
username: "{{ xenserver_username }}"
password: "{{ xenserver_password }}"
name: testvm_11
state: powered-on
delegate_to: localhost
register: facts
Common return values are documented here, the following are the fields unique to this module:
Key | Description |
|---|---|
instance dictionary | Metadata about the VM. Returned: always Sample: |
© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/general/xenserver_guest_powerstate_module.html