# Unsupported parameters for (copy) module: when

**URL:** <https://forum.ansible.com/t/unsupported-parameters-for-copy-module-when/25138>\
**Category:** Ansible Project\
**Created:** [July 31, 2017, 5:26pm UTC](https://forum.ansible.com/t/unsupported-parameters-for-copy-module-when/25138 "2017-07-31T17:26:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mark.haney](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@mark.haney](https://forum.ansible.com/u/mark.haney)\
**Post date:** [July 31, 2017, 5:26pm UTC](https://forum.ansible.com/t/unsupported-parameters-for-copy-module-when/25138/1 "2017-07-31T17:26:03Z")

</div>

I’ve got a task I’m trying to run, where a file gets copied if that file has changed. It’s a local file (though it’s copied from a remote to a local destination first) and I want to copy it to several hosts. When I run the task it bombs with

Unsupported parameters for (copy) module: when. Supported parameters include: attributes,backup,content,delimiter,dest,directory\_mode,follow,force,group,mode,original\_basename,owner,regexp,remote\_src,selevel,serole,setype,seuser,src,unsafe\_writes,validate

Here’s the part of the play that’s relevant:

tasks:

- name: get stat of files  
stat:  
path: files/WHITELIST-squash.txt  
register: whitelist

- name: Push to mail proxies  
copy:  
src: files/WHITELIST-squash.txt  
dest: /root/bin/postfixFindSpammers.ignore  
backup: yes  
when: whitelist.stat.changed

The problem is, when I’ve googled the copy module, other sources are saying ‘when’ can be used with it. The documentation doesn’t, so what’s the bloody deal here? Can or can you not use when with copy? To me, this seems silly to have that option. I’ve noticed that you can use when with a template, which is nothing but a copy with some dynamic editing thrown in.

I don’t get it. Any ideas?

---

<div class="post-metadata">

**Author:** ![Nils\_Steinger](https://avatars.discourse-cdn.com/v4/letter/n/71e660/32.png) [@Nils\_Steinger](https://forum.ansible.com/u/Nils_Steinger)\
**Post date:** [July 31, 2017, 5:50pm UTC](https://forum.ansible.com/t/unsupported-parameters-for-copy-module-when/25138/2 "2017-07-31T17:50:15Z")

</div>

Your indentation is a little off:

> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- name: Push to mail proxies  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;copy:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;src: files/WHITELIST-squash.txt  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dest: /root/bin/postfixFindSpammers.ignore  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;backup: yes  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when: whitelist.stat.changed

`when:` is \*below\* `copy:`, so it's passed to the copy module instead of  
being processed by Ansible itself (like the `register:` you're already  
using correctly).  
Bring it to the same indentation level as your module invocation instead:

> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- name: Push to mail proxies  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;copy:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;src: files/WHITELIST-squash.txt  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dest: /root/bin/postfixFindSpammers.ignore  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;backup: yes  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when: whitelist.stat.changed

Best,  
Nils

---

<div class="post-metadata">

**Author:** ![mark.haney](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@mark.haney](https://forum.ansible.com/u/mark.haney)\
**Post date:** [July 31, 2017, 5:57pm UTC](https://forum.ansible.com/t/unsupported-parameters-for-copy-module-when/25138/3 "2017-07-31T17:57:35Z")

</div>

It's funny, I tried that and it gave me the same error. Oh well. I found a way around the problem, sometimes the Jeremy Clarkson hammer method is best.

Thanks for the help.

---

<div class="post-metadata">

**Author:** ![Nils\_Steinger](https://avatars.discourse-cdn.com/v4/letter/n/71e660/32.png) [@Nils\_Steinger](https://forum.ansible.com/u/Nils_Steinger)\
**Post date:** [July 31, 2017, 6:05pm UTC](https://forum.ansible.com/t/unsupported-parameters-for-copy-module-when/25138/4 "2017-07-31T18:05:15Z")

</div>

Mixed tabs and spaces perhaps?  
And saying "below" might have been a bit ambiguous: it's all about the  
indentation; ordering doesn't matter.

Best,  
Nils

---

<div class="post-metadata">

**Author:** ![mark.haney](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@mark.haney](https://forum.ansible.com/u/mark.haney)\
**Post date:** [July 31, 2017, 6:11pm UTC](https://forum.ansible.com/t/unsupported-parameters-for-copy-module-when/25138/5 "2017-07-31T18:11:57Z")

</div>

I'm aware of that. And my syntax check cleared fine. Sublime 3 has a great YAML syntax highlighter, and I made sure backspace to the beginning of the line and space over, because I'm so used to TAB indentation that I've borked files several times. Maybe I missed something like that, but it's moot now, I threw a nuke at it instead of a hand grenade to get it done and working.
