I was attempting to launch an application through an Ansible Tower job in a remote Windows VM. I’m logged into the remote PC with the same credentials with which my Ansible playbooks are run. For the sake of simplicity, my playbook is like this -
name: Register and turn on VMs
hosts: all
tasks:
name: Start VM
raw: notepad
I expect the above playbook to launch notepad in GUI mode on the remote Windows PC I’m connected to. However, this only adds up a process for notepad.exe but the GUI doesn’t appear. The tower job does not complete either and I end up canceling it. How to ensure that the application launches with a GUI and not as a process?
Ignore those names: I am trying to achieve something else (i.e., turning on VMs but I need them to come up in GUI mode. I guess if notepad can come up, I will figure out the rest.
I’m fairly certain you won’t have a GUI session, so I think windows has no way of knowing which session to display the notepad user interface in.
You might be able to get a session established by setting auto logon (if you can live with implications of using auto logon) - there’s a powershell script here that can set autologon http://poshcode.org/2982
In my case, I have an active GUI session. I’m using it to verify if things are working as expected.
Another approach which I have tried in the meantime is using psexec which is known to be helpful in such cases, that is to show the GUI. While I was able to launch notepad.exe by using the psexec executable on the client machine, Ansible used to report the operation as failed. .
Don’t Ansible users use GUI at any point in time to verify if the operations are running as expected? Are end-to-end operations run in an unattended fashion?
Its true that some of the checking I do does rely on Powershell, although often this can be accomplished with a single-line Powershell command, for example
`
name: check if Windows8.1-KB2999226-x64.msu hotfix has been applied
raw: Get-Hotfix -Id KB2999226
register: hotfix_status
ignore_errors: true
`
I’ve used Get-Process in a similar way - something like