# Help understanding the copy module's "validate" parameter

**URL:** <https://forum.ansible.com/t/help-understanding-the-copy-modules-validate-parameter/16335>\
**Category:** Ansible Project\
**Created:** [September 25, 2014, 11:20am UTC](https://forum.ansible.com/t/help-understanding-the-copy-modules-validate-parameter/16335 "2014-09-25T11:20:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan\_Bohea](https://avatars.discourse-cdn.com/v4/letter/d/e19b73/32.png) [@Dan\_Bohea](https://forum.ansible.com/u/Dan_Bohea)\
**Post date:** [September 25, 2014, 11:20am UTC](https://forum.ansible.com/t/help-understanding-the-copy-modules-validate-parameter/16335/1 "2014-09-25T11:20:40Z")

</div>

Pretty sure I need to use the validate parameter in a copy task but am unclear on how to use it.

Here’s my copy task for context:

`

`

- copy: src={{ item }} dest=/home/vagrant/.drush/{{ boxname }}.aliases.drushrc.php  
`

with\_fileglob:

- …/…/settings/drush\_aliases/\*  
notify: drush cc drush  
when: php\_install is defined and php\_install == “y”  
tags: drush\_aliases

`

I guess the only bit we need to focus on here is:

`

- copy: src={{ item }} dest=/home/vagrant/.drush/{{ boxname }}.aliases.drushrc.php

with\_fileglob:

- …/…/settings/drush\_aliases/\*

`

I’d like to make sure that only certain files can be copied from …/…/settings/drush\_aliases/\*

Things like:

1. Only files with a .php extension
2. Only 1 file can be copied (fail if the directory contains multiple)  
Any pointers on how I might achieve this?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [September 25, 2014, 12:05pm UTC](https://forum.ansible.com/t/help-understanding-the-copy-modules-validate-parameter/16335/2 "2014-09-25T12:05:23Z")

</div>

Hi,

validate is for basically running things like visudo against a sudoers file before finally copying it in place over the file. This wouldn’t be a good fit here.

It seems that what you would want to do, instead, is adapt your fileglob to only accept those files, or instead, name those files explicitly.

Sort of make sense?

Thanks!

---

<div class="post-metadata">

**Author:** ![Dan\_Bohea](https://avatars.discourse-cdn.com/v4/letter/d/e19b73/32.png) [@Dan\_Bohea](https://forum.ansible.com/u/Dan_Bohea)\
**Post date:** [September 25, 2014, 12:06pm UTC](https://forum.ansible.com/t/help-understanding-the-copy-modules-validate-parameter/16335/3 "2014-09-25T12:06:43Z")

</div>

Not sure why I didn’t think of that! Thanks.
