The last working commit I can find which works on windows is ca e2e9319f06b058098cdf4272689766abb95b80f2 (https://github.com/ansible/ansible/commit/e2e9319f06b058098cdf4272689766abb95b80f2) note that I haven’t tried all of them. From the logs it looks like ansible is trying to run python code on windows:
elk.admigration.local | FAILED! => {
“changed”: false,
“failed”: true,
“msg”: “#< CLIXML\r\n<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04\”><Obj S="progress" RefId="0"><TN RefId="0">System.Management.Automation.PSCustomObjectSystem.Object<I64 N="SourceId">1<PR N="Record">Preparing modules for first use.0-1-1Completed-1 <Obj S="progress" RefId="1"><TNRef RefId="0" /><I64 N="SourceId">1<PR N="Record">Preparing modules for first use.0-1-1Completed-1 <S S="Error">/usr/bin/python : The term ‘/usr/bin/python’ is not recognized as the name of x000D__x000A<S S="Error">a cmdlet, function, script file, or operable program. Check the spelling of x000D__x000A<S S="Error">the name, or if a path was included, verify that the path is correct and try x000D__x000A<S S="Error">again.x000D__x000A<S S="Error">At line:1 char:7_x000D__x000A_<S S="Error">+ Try { /usr/bin/python "C:\Users\ansible\AppData\Local\Temp\ansible-tm …x000D__x000A<S S="Error">+ ~~~~~~~~~~~~~~~x000D__x000A<S S="Error"> + CategoryInfo : ObjectNotFound: (/usr/bin/python:String) , Par x000D__x000A<S S="Error"> entContainsErrorRecordException_x000D__x000A_<S S="Error"> + FullyQualifiedErrorId : CommandNotFoundException_x000D__x000A_<S S="Error"> x000D__x000A",
“parsed”: false
Hi Chris,
Can you tell me whether this issue is fixed in ansible version: 2.0.0.2 as I’m having an issue while running ansible playbook on aws windows instances.
My playbook looks like this:
-
name: ensure security group is present
ec2_group:
name: WinRM RDP
description: Inbound WinRM and RDP
region: “{{ target_aws_region }}”
rules:
-
proto: tcp
from_port: 80
to_port: 80
cidr_ip: 0.0.0.0/0
-
proto: tcp
from_port: 5986
to_port: 5986
cidr_ip: 0.0.0.0/0
-
proto: tcp
from_port: 3389
to_port: 3389
cidr_ip: 0.0.0.0/0
rules_egress:
-
proto: -1
cidr_ip: 0.0.0.0/0
register: sg_out
-
ec2_ami_find:
region: “{{ target_aws_region }}”
platform: windows
virtualization_type: hvm
owner: amazon
name: Windows_Server-2012-R2_RTM-English-64Bit-Base-*
no_result_action: fail
sort: name
sort_order: descending
register: found_amis
None of these modules: ec2_group, ec2_ami_find work for me as it throws this error:
An exception occurred during task execution. The full traceback is:
At line:4 char:1
- /usr/bin/python "C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-145442138 …
-
fatal: [aws-win-host]: FAILED! => {“changed”: false, “failed”: true, “invocation”: {“module_name”: “ec2_group”}, “msg”: “The term ‘/usr/bin/python’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.”}
Please tell me if I’m doing something wrong.
Thanks,
Balaji
I have 2.0.0.2 working fine with local windows machines.
Are you running from source? If so perhaps you need to update your submodules
Hope this helps,
Jon
Hi jhawkesworth,
Yes I’m running from source.
I have cloned the git repository with option set to --recursive and also i have updated the submodules using git submodule update --init --recursive.
Still it’s not working.
While checking the logs, i found that it was using /usr/bin/python in place of C:/Python27/python.
Try
{
C:/Python27/python “C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1454428251.01-120917033280940\ec2_ami_find.ps1”
}
Catch
So i added this in aws_hosts file:
aws-win-host ansible_ssh_host=52.18.216.106 ansible_python_interpreter=“C:/Python27/python”
But now i get this error:
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
File “C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-1454428251.01-120917033280940\ec2_ami_find.ps1”, line 484, in
import grp
ImportError: No module named grp
fatal: [aws-win-host]: FAILED! => {“changed”: false, “failed”: true, “invocation”: {“module_name”: “ec2_ami_find”}, “parsed”: false}
Thanks,
Balaji
I am not familiar with the ec2 modules but I imagine that you need to run them on the ansible controller by using delegate_to: localhost as the scripting language used by ansible on windows hostsis powershell, not python.
I suggest reading http://docs.ansible.com/playbooks_delegation.html
Hope this helps,
Jon
Looks like this is the github issue for tracking this: https://github.com/ansible/ansible/issues/14233
Balaji Chandrababu,
Did you ever figure out a resolution to this issue? I’m having the same problem and not coming up with any solutions.
Thanks,
Sam
Hi, I am facing same issue. Have you found the solution?
This is a very old thread, the original issue described here was fixed before ansible 2.0 was released (over a year ago now).
What version of ansible are you using? Are you running from source?
If you can share a specific playbook that isn’t working I can help (I use ansible against windows all the time).
Jon
Thanks for the quick responce
I am new to ansible and to download some files from s3 bucket, using s3 module.
Ansible version 2.2.1.0
Error :
an exception occurred during task execution. The full traceback is:
At line:4 char:1
- /usr/bin/python 'C:\Users\Administrator\AppData\Local\Temp\ansible-tmp-149008935 …
-
fatal: [ec2-52-200-207-123.compute-1.amazonaws.com]: FAILED! => {
“changed”: false,
“failed”: true,
“invocation”: {
“module_name”: “s3”
},
“msg”: “The term ‘/usr/bin/python’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.”
}
my playbook:
- name: Downloading TcRS base kits from S3
s3:
bucket: “{{s3_bucket_app_kits}}”
object: “{{zip_base_kit_1_wnt}}”
dest: “{{dir_base_loc}}”
mode: get
Is it correct or is there any different module for windows?
Thanks,
Sayali
Windows modules use powershell, not python so this won’t work straight onto a windows machine.
You might be able to work around it by downloading from s3 to your ansible controller and then using win_copy to copy whatever it is you want to your windows machines. But a module would save you downloading to an intermediate machine first.