community.vmware
community.vmware copied to clipboard
vmware_guest_sendkey: handle special keys in string_send and other improvements
SUMMARY
After using hashicorp packer for a while, I got used to the boot_command way of handling sendkeys. After learning about the sendkey module for ansible community.vmware, I missed the packer style... So i decided to keep string_send for backward compatibility, create the strings_send param as a list of strings. Then added handling of key vars like ENTER -> <ENTER> , ESC -> <ESC> Escaping is supported: \<WAIT> \<ESC> , etc
Another improvement is changind sleep_time from int to float to allow fractions of seconds
Special note about this string "\<WAIT> A<TAB\<TAB>asdf> \<TAB<ENTER>A>" The first part of "\<TAB<ENTER>A>" Will output as "\<TAB" intead of "<TAB". I wasn't able to debug for a fix in the regex.
ISSUE TYPE
- Docs Pull Request
- Feature Pull Request
COMPONENT NAME
vmware_guest_sendkey
ADDITIONAL INFORMATION
Example:
- name: "Send keystrokes to VM"
community.vmware.vmware_guest_sendkey:
hostname: "{{ vsphere_hostname }}"
username: "{{ vsphere_username }}"
password: "{{ vsphere_password }}"
validate_certs: false
folder: "{{ vsphere_datacenter }}/vm"
name: "{{ dest_vm }}"
sleep_time: 0.1 #This patch allows float values here
string_send: "TESTING<ENTER>" #Prepended to the strings_send list
strings_send:
- "<ESC>:1,$d<ENTER>iA tab<TAB>y<WAIT0><ENTER>" #Testing on an open vim instance
- "\\<WAIT> A<TAB\\<TAB>asdf> \\<TAB<ENTER>A>" #Possibly bugged string
- "TESTING<WAIT><ENTER>"
- "TABBING<TAB>WORKS<WAIT><ENTER>"
keys_send:
- <TAB>
- <ENTER>
delegate_to: localhost
Build failed.
:x: ansible-tox-linters FAILURE in 3m 58s :heavy_check_mark: build-ansible-collection SUCCESS in 4m 19s :x: ansible-test-sanity-docker-devel FAILURE in 9m 22s (non-voting) :x: ansible-test-sanity-docker-milestone FAILURE in 10m 24s :x: ansible-test-sanity-docker-stable-2.11 FAILURE in 10m 00s :x: ansible-test-sanity-docker-stable-2.12 FAILURE in 9m 15s :heavy_check_mark: ansible-test-units-community-vmware-python27 SUCCESS in 5m 06s :heavy_check_mark: ansible-test-units-community-vmware-python36 SUCCESS in 5m 48s :heavy_check_mark: ansible-test-units-community-vmware-python37 SUCCESS in 6m 31s :heavy_check_mark: ansible-test-units-community-vmware-python38 SUCCESS in 6m 23s :heavy_check_mark: ansible-test-cloud-integration-vcenter7_only-python36-stable211 SUCCESS in 19m 50s :heavy_check_mark: ansible-test-cloud-integration-vcenter7_2esxi-python36-stable211 SUCCESS in 20m 00s :heavy_check_mark: ansible-test-cloud-integration-vcenter7_1esxi-python36-stable211_1_of_2 SUCCESS in 1h 01m 41s :heavy_check_mark: ansible-test-cloud-integration-vcenter7_1esxi-python36-stable211_2_of_2 SUCCESS in 42m 00s :heavy_check_mark: ansible-galaxy-importer SUCCESS in 5m 24s
Build failed.
:x: ansible-tox-linters FAILURE in 4m 23s :heavy_check_mark: build-ansible-collection SUCCESS in 5m 43s :x: ansible-test-sanity-docker-devel FAILURE in 9m 43s (non-voting) :x: ansible-test-sanity-docker-milestone FAILURE in 13m 51s :x: ansible-test-sanity-docker-stable-2.11 FAILURE in 11m 43s :x: ansible-test-sanity-docker-stable-2.12 FAILURE in 10m 02s :heavy_check_mark: ansible-test-units-community-vmware-python27 SUCCESS in 4m 26s :heavy_check_mark: ansible-test-units-community-vmware-python36 SUCCESS in 6m 09s :heavy_check_mark: ansible-test-units-community-vmware-python37 SUCCESS in 5m 04s :heavy_check_mark: ansible-test-units-community-vmware-python38 SUCCESS in 5m 40s :heavy_check_mark: ansible-test-cloud-integration-vcenter7_only-python36-stable211 SUCCESS in 20m 49s :heavy_check_mark: ansible-test-cloud-integration-vcenter7_2esxi-python36-stable211 SUCCESS in 19m 36s :heavy_check_mark: ansible-test-cloud-integration-vcenter7_1esxi-python36-stable211_1_of_2 SUCCESS in 1h 02m 22s :x: ansible-test-cloud-integration-vcenter7_1esxi-python36-stable211_2_of_2 FAILURE in 12m 04s :heavy_check_mark: ansible-galaxy-importer SUCCESS in 4m 02s
Build failed.
:heavy_check_mark: ansible-tox-linters SUCCESS in 4m 02s :heavy_check_mark: build-ansible-collection SUCCESS in 4m 07s :heavy_check_mark: ansible-test-sanity-docker-devel SUCCESS in 9m 18s (non-voting) :heavy_check_mark: ansible-test-sanity-docker-milestone SUCCESS in 9m 27s :heavy_check_mark: ansible-test-sanity-docker-stable-2.11 SUCCESS in 10m 49s :heavy_check_mark: ansible-test-sanity-docker-stable-2.12 SUCCESS in 8m 19s :heavy_check_mark: ansible-test-units-community-vmware-python27 SUCCESS in 6m 39s :heavy_check_mark: ansible-test-units-community-vmware-python36 SUCCESS in 5m 18s :heavy_check_mark: ansible-test-units-community-vmware-python37 SUCCESS in 5m 10s :heavy_check_mark: ansible-test-units-community-vmware-python38 SUCCESS in 7m 02s :heavy_check_mark: ansible-test-cloud-integration-vcenter7_only-python36-stable211 SUCCESS in 20m 28s :heavy_check_mark: ansible-test-cloud-integration-vcenter7_2esxi-python36-stable211 SUCCESS in 17m 18s :x: ansible-test-cloud-integration-vcenter7_1esxi-python36-stable211_1_of_2 FAILURE in 13m 20s :x: ansible-test-cloud-integration-vcenter7_1esxi-python36-stable211_2_of_2 FAILURE in 17m 05s :heavy_check_mark: ansible-galaxy-importer SUCCESS in 5m 49s
recheck
Build succeeded.
:heavy_check_mark: ansible-tox-linters SUCCESS in 4m 01s :heavy_check_mark: build-ansible-collection SUCCESS in 4m 32s :heavy_check_mark: ansible-test-sanity-docker-devel SUCCESS in 11m 52s (non-voting) :heavy_check_mark: ansible-test-sanity-docker-milestone SUCCESS in 10m 06s :heavy_check_mark: ansible-test-sanity-docker-stable-2.11 SUCCESS in 10m 49s :heavy_check_mark: ansible-test-sanity-docker-stable-2.12 SUCCESS in 10m 00s :heavy_check_mark: ansible-test-units-community-vmware-python27 SUCCESS in 5m 42s :heavy_check_mark: ansible-test-units-community-vmware-python36 SUCCESS in 6m 06s :heavy_check_mark: ansible-test-units-community-vmware-python37 SUCCESS in 5m 34s :heavy_check_mark: ansible-test-units-community-vmware-python38 SUCCESS in 5m 07s :heavy_check_mark: ansible-test-cloud-integration-vcenter7_only-python36-stable211 SUCCESS in 20m 48s :heavy_check_mark: ansible-test-cloud-integration-vcenter7_2esxi-python36-stable211 SUCCESS in 18m 25s :heavy_check_mark: ansible-test-cloud-integration-vcenter7_1esxi-python36-stable211_1_of_2 SUCCESS in 1h 02m 46s :heavy_check_mark: ansible-test-cloud-integration-vcenter7_1esxi-python36-stable211_2_of_2 SUCCESS in 43m 57s :heavy_check_mark: ansible-galaxy-importer SUCCESS in 4m 19s
Do I need to do something else, or just wait for an approval/merge of the feature?
@msilveirabr It looks like there are several people working on this module at the moment. There are also PRs #1390 and #1414.
So I suggest you, @jason-neumann and @ziegenberg join forces.