-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using plugin with windows vm's #92
Comments
Hi @dennisvanderveen, thanks for reporting this. I am not too familiar with Windows, but I'll see if I can set something up to replicate your issue. In the mean time, can I check that you have QEMU guest agent up and running in your Windows VMs and that they have a serial device for it? And can you manually run a command against your host to create a file in it at virsh qemu-agent-command windows '{"execute":"guest-exec", "arguments":{"path":"cmd.exe","arg":["/c","echo 123 > c:\\123.txt"]}}' --pretty Seems like the issue might be as you say, that the default command is I'll have a look and see what I can find. -c |
Qemu agent is up and running for the windows vm.
|
If you add the argument community.libvirt/plugins/connection/libvirt_qemu.py Lines 30 to 34 in 3c66295
|
I tried and failed, with and without full path. Both variables. Also tried it as a variable in a play |
I found the same thing and I'm not sure how this is mean to work. @daveol do you have any idea on this one and what we should try? Thanks! |
If I remember this correctly (it has been a while), you will need to set |
@daveol thanks so much for the response, really appreciated! That seems to make the code hit the right path now, cheers. @dennisvanderveen are you able to give that a go? I have done a basic test which fails due to differences in the Windows Python distribution I guess (I probably need to use a $ ansible -i ../../kvm.yml all --limit win10 -m ping -e ansible_shell_type=cmd -e "ansible_python_interpreter=C:\Users\csmart\AppData\Local\Programs\Python\Python39\python.exe"
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or trying out features under development. This is a rapidly changing source of code and can
become unstable at any point.
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError: No module named 'grp'
win10 | FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\r\n File \"C:\\Windows\\TEMP\\ansible-tmp-1643526789.9121494-73396-242370585012302\\AnsiballZ_ping.ps1\", line 107, in <module>\r\n _ansiballz_main()\r\n File \"C:\\Windows\\TEMP\\ansible-tmp-1643526789.9121494-73396-242370585012302\\AnsiballZ_ping.ps1\", line 99, in _ansiballz_main\r\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n File \"C:\\Windows\\TEMP\\ansible-tmp-1643526789.9121494-73396-242370585012302\\AnsiballZ_ping.ps1\", line 44, in invoke_module\r\n from ansible.module_utils import basic\r\n File \"<frozen zipimport>\", line 259, in load_module\r\n File \"C:\\Windows\\TEMP\\ansible_ping_payload_3ebhir5s\\ansible_ping_payload.zip\\ansible\\module_utils\\basic.py\", line 39, in <module>\r\nModuleNotFoundError: No module named 'grp'\r\n",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
} |
also adding it to host_vars makes it work
So thx for all the help. Maybe is good to add this to the comments of libvirt_qemu.py and mayby to ansible-doc aswell? |
@dennisvanderveen if you have time, I'd appreciate if you could cast your eye over the PR linked above to clarify the docs. It seems to me that |
Will do Chris! Will let you know |
Thanks, in particular I think we should clarify whether |
I can confirm using powershell works also
|
SUMMARY
How to use the inventory plugin with windows vm?
when using ansible-inventory not many hostvars are showing to use, only ansible_connection and ansible_libvirt_uri
when using ansible ad-hoc commands or using the inventory plugin in playbooks it defaults to /bin/sh
I found #37 where windows is added to the connection plugin, but for me it's unclear how to use this.
ISSUE TYPE
COMPONENT NAME
community.libvirt.libvirt_qemu connection plugin
ANSIBLE VERSION
The text was updated successfully, but these errors were encountered: