ERROR: win_file is not a legal parameter in an Ansible task or handler

1,076 views
Skip to first unread message

Slim Slam

unread,
Jun 9, 2015, 11:58:03 PM6/9/15
to ansible...@googlegroups.com
Running Ansible v1.9.1 under MacOSX 10.10.3

Trying to use Ansible to configure Windows Server 2008 and am having some basic problem.
The server is running on Amazon AWS. I've got all the connection stuff working fine.
This (mostly empty) Ansible playbook runs fine:

---
# Buildit.yml


- name: Configure The Server
  hosts
: '{{ machine }}'
  remote_user
: Administrator
  gather_facts
: True
  vars
:
    workdirectory
: 'C:\funstuff'
    logdirectory
: 'C:\Windows\System32\winevt\Logs'
  tasks
:


$ ansible-playbook -v -i ../windows_servers  BuildIt.yml --e "machine=winserv"

PLAY [Configure The Server] ***************************************************


GATHERING FACTS
***************************************************************
ok
: [52.8.8.11] => {"ansible_facts": {"ansible_distribution": "Microsoft Windows NT 6.3.9600.0", "ansible_distribution_version": "6.3.9600.0", "ansible_fqdn": "WIN-Q6VQ4JB2KCU", "ansible_hostname": "WIN-Q6VQ4JB2KCU", "ansible_interfaces": [{"default_gateway": "172.31.16.1", "dns_domain": "us-east-1.compute.internal", "interface_index": 12, "interface_name": "AWS PV Network Device #0"}], "ansible_ip_addresses": ["172.3.4.18", "fe80::8a9:7fe:537:75e"], "ansible_os_family": "Windows", "ansible_powershell_version": 4, "ansible_system": "Win32NT", "ansible_totalmem": 8053063680, "ansible_winrm_certificate_expires": "2016-06-09 16:18:39"}, "changed": false}


PLAY RECAP
********************************************************************
52.8.8.11               : ok=1    changed=0    unreachable=0    failed=0

But if I add one task, it fails:

---
# Buildit.yml


- name: Configure The Server
  hosts
: '{{ machine }}'
  remote_user
: Administrator
  gather_facts
: True
  vars
:
    workdirectory
: 'C:\funstuff'
    logdirectory
: 'C:\Windows\System32\winevt\Logs'
  tasks
:
   
- name: make sure work directory exists
      win_file
: path=C:\funstuff state=directory

$ ansible-playbook -v -i ../windows_servers  BuildIt.yml --e "machine=winserv"
ERROR: win_file is not a legal parameter in an Ansible task or handler
$

Why am I getting this error?


benno joy

unread,
Jun 10, 2015, 12:12:12 AM6/10/15
to ansible...@googlegroups.com
Hi,

How did you install ansible, if it is a checkout did you --recursive to add the submodules ? seems like ansible is not able to see the modules in the modules path.



--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b6ff652c-49d4-42cd-83af-87f2aea55f19%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

J Hawkesworth

unread,
Jun 10, 2015, 1:54:07 AM6/10/15
to ansible...@googlegroups.com
Actually win_copy and win_file were not included in 1.9.1. They are in 1.9.2 rc1 but there were a couple of issues with win_copy for which I have made fixes. I hope these will be incorporated into 1.9.2 rc2.

Jon

Slim Slam

unread,
Jun 10, 2015, 8:19:31 AM6/10/15
to ansible...@googlegroups.com
I've been installing Ansible using pip, e.g.  "sudo pip install --upgrade ansible"

By the way, if the only task I have is this one:

tasks:
 
- win_chocolatey:
    name
: PSWindowsUpdate
    state
: present

I get this error:

ERROR: state is not a legal parameter in an Ansible task or handler

I can't get any of the Windows tasks to work, but the Linux stuff works fine.

Slim Slam

unread,
Jun 10, 2015, 8:23:53 AM6/10/15
to ansible...@googlegroups.com
I think these might be the relevant module directories on my Mac:

$ ls /Library/Python/2.7/site-packages/ansible/modules/core/windows
__init__
.py win_feature.ps1 win_get_url.py win_group.pyc win_ping.ps1 win_service.py win_stat.pyc
__init__
.pyc win_feature.py win_get_url.pyc win_msi.ps1 win_ping.py win_service.pyc win_user.ps1
setup
.ps1 win_feature.pyc win_group.ps1 win_msi.py win_ping.pyc win_stat.ps1 win_user.py
slurp
.ps1 win_get_url.ps1 win_group.py win_msi.pyc win_service.ps1 win_stat.py win_user.pyc

AND

$ ls /Library/Python/2.7/site-packages/ansible/modules/extras/windows
__init__
.py win_chocolatey.ps1 win_chocolatey.pyc win_updates.py
__init__
.pyc win_chocolatey.py win_updates.ps1 win_updates.pyc

J Hawkesworth

unread,
Jun 10, 2015, 8:43:33 AM6/10/15
to ansible...@googlegroups.com
I don't have a mac to try this out on but it seems you aren't picking up your modules.

I did a quick search and I found a couple of threads that might be relevant:



I suggest

1/ trying a clean ansible installation, if possible
2/ checking your playbook for invalid yaml (use a yaml-aware text editor like notepad++ or www.yamllint.com)

Hope this helps,

Jon

Slim Slam

unread,
Jun 10, 2015, 9:51:05 AM6/10/15
to ansible...@googlegroups.com
I did "sudo pip uninstall ansible"  and then "sudo pip install ansible".  Made no difference.

yamllint.com says that my ansible script is valid.

I'm stumped.

J

Slim Slam

unread,
Jun 10, 2015, 12:22:45 PM6/10/15
to ansible...@googlegroups.com
Ok. I filed a documentation bug on the two windows modules which are not in Ansible 1.9.1 (but the docs don't mention that):
https://github.com/ansible/ansible/issues/11220

After some further testing, it appears that the windows modules in the "core/windows" directory
work ok.  However, the windows modules in the "extras/windows" directory don't seem to be loading. 

Is my search path correct?

$ ansible --version
ansible
1.9.1
  configured
module search path = /Library/Python/2.7/site-packages/ansible/modules/core:/Library/Python/2.7/site-packages/ansible/modules/extras

-J

J Hawkesworth

unread,
Jun 10, 2015, 4:29:45 PM6/10/15
to ansible...@googlegroups.com
Have you set the module search path by modifying your ansible.cfg?

My 1.9.1 install shows

   configured module search path = None

unless I set a library= value in my ansible.cfg  (maybe cos I originally installed from yum though).

Slim Slam

unread,
Jun 10, 2015, 10:14:15 PM6/10/15
to ansible...@googlegroups.com
It originally said "path = None" but I then explicitly set the path. It didn't make
a difference. Still broken. Are you able to access update and chocolatey?

J

J Hawkesworth

unread,
Jun 11, 2015, 12:02:59 PM6/11/15
to ansible...@googlegroups.com
I haven't tried chocolatey but I can get win_updates to execute.  But my ansible was installed via yum and I'm not on a mac.

It does feel like something is stopping ansible from finding parts of itself.  Have you upgraded from an older ansible version (or did you start with a fresh 1.9.1 install the first time)?  Have you ever also pulled directly from github?

Jon

Slim Slam

unread,
Jun 11, 2015, 12:27:51 PM6/11/15
to ansible...@googlegroups.com
If you look back  through this thread, you'll see that I unistalled and then reinstalled Ansible. It didn't change anything.
The core windows modules work, but not the windows modules in extras.

J

Jake Dupuy

unread,
Jun 11, 2015, 12:37:59 PM6/11/15
to ansible...@googlegroups.com
I've got a similar issue, I need to get win_file working for one of my plays. Sounds like upgrade to 1.9.2 should do the trick?

Slim Slam

unread,
Jun 11, 2015, 12:40:39 PM6/11/15
to ansible...@googlegroups.com
Since v1.9.2 is not released yet, is there a way to use pip to upgrade to the latest development version of 1.9.2?

J

J Hawkesworth

unread,
Jun 11, 2015, 1:35:24 PM6/11/15
to ansible...@googlegroups.com
I think latest devel is only available by cloning from github.

I am hoping there will be a 1.9.2 release candidate 2 soon which might include these modules.

Jon
Reply all
Reply to author
Forward
0 new messages