community.proxmox.proxmox_sendkey module – Send key presses to a Proxmox VM console

Note

This module is part of the community.proxmox collection (version 1.5.0).

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.proxmox. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: community.proxmox.proxmox_sendkey.

New in community.proxmox 1.5.0

Synopsis

  • Uses the Proxmox API to send a sequence of key presses to the console of a VM.

  • Keys can be specified explicitly or derived from a plain text string.

Requirements

The below requirements are needed on the host that executes this module.

  • proxmoxer >= 2.0

  • requests

Parameters

Parameter

Comments

api_host

string / required

Specify the target host of the Proxmox VE cluster.

Uses the PROXMOX_HOST environment variable if not specified.

api_password

string

Specify the password to authenticate with.

Uses the PROXMOX_PASSWORD environment variable if not specified.

api_port

integer

Specify the target port of the Proxmox VE cluster.

Uses the PROXMOX_PORT environment variable if not specified.

api_token_id

string

Specify the token ID.

Uses the PROXMOX_TOKEN_ID environment variable if not specified.

api_token_secret

string

Specify the token secret.

Uses the PROXMOX_TOKEN_SECRET environment variable if not specified.

api_user

string / required

Specify the user to authenticate with.

Uses the PROXMOX_USER environment variable if not specified.

delay

float

Delay in seconds between each key press.

Default: 0.0

keys_send

list / elements=string

List of keys or key sequence to send in order.

Each item must follow the qemu key naming format such as ctrl-alt-delete or ret.

You can specify either keys_send or string_send.

name

string

The unique name of the VM.

string_send

string

Raw string that will be transformed to the corresponding key presses

Only ASCII-characters are supported. before sending.

You can specify either keys_send or string_send.

validate_certs

boolean

If false, SSL certificates will not be validated.

This should only be used on personally controlled sites using self-signed certificates.

Uses the PROXMOX_VALIDATE_CERTS environment variable if not specified.

Choices:

  • false ← (default)

  • true

vmid

integer

The unique ID of the VM.

Takes precedence over name.

Attributes

Attribute

Support

Description

action_group

Action group: community.proxmox.proxmox

Use group/community.proxmox.proxmox in module_defaults to set defaults for this module.

check_mode

Support: none

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: none

Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode.

Notes

Note

Examples

- name: Send Ctrl+Alt+Delete to a Windows VM
  proxmox_sendkey:
    api_host: proxmoxhost
    api_user: root@pam
    api_password: password123
    name: win-test
    keys_send:
      - ctrl-alt-delete

- name: Type a login string into a Linux VM console
  proxmox_sendkey:
    api_host: proxmoxhost
    api_user: root@pam
    api_password: password123
    vmid: 101
    string_send: |
        root
        P@ssw0rd
    delay: 1.0

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

completed_keys_num

integer

Number of keys that were sent to the VM console.

Returned: success

Sample: 5

keys_num

integer

Number of sent keys that were sent to the VM console.

Returned: success

Sample: 5

total_keys

list / elements=string

List of sent keys that were sent to the VM console.

Returned: success

Sample: ["H", "e", "l", "l", "o"]

vmid

integer

The VM vmid.

Returned: success

Sample: 101

Authors

  • miyuk (@miyuk172)