Hi!
I am having an issue with ansible interacting with powershell on a windows-machine. The Problem disappears when using verbose mode, which makes it a bit difficult to debug.
I am using ansible 2.18.1 on a linux machine, connecting via ssh to a windows machine running OpenSSH-Server. The necessary registry-keys are configured so powershell is used as the default shell. Connecting to the target using ssh -i path/to/keyfile user@target
works fine and I am able to type and execute powershell commands.
I have played around with ansible-playbooks and ad-hoc-commands as well and at first they were working fine, until a few weeks ago (I can’t think of anything relevant I have changed since), when my playbooks as well as my ad-hoc-commands are failing with the following message:
$ ansible target -m win_ping
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, column 260
target | FAILED! => {
"msg": "Unexpected failure during module execution: not well-formed (invalid token): line 1, column 260",
"stdout": ""
}
This was the output of ansible target -m win_ping
(with username and ssh-keyfile being configured in my inventory file), but it is the same issue when I execute -m win_shell -a "whoami"
, a playbook using the ansible.windows.win_updates-module or anything else.
The error message advices me to use the -vvv
-option, and when I execute the same command in verbose mode (starting with -v
), it works absolutely fine.
$ ansible -v target -m win_ping
No config file found; using defaults
target | SUCCESS => {
"changed": false,
"ping": "pong"
}
When using the ENV-Variable ANSIBLE_DEBUG=true
with the command, but without -v
, the command still fails.
I have tried this with 3 different Windows-machines as targets, issue is always identical.
I would be happy to see what line 1, column 260 contains, but I have no idea how to debug it. Running all my commands with -v
all the time wouldn’t be my prefered solution either…