# Bug in copy module for directory\_mode?

**URL:** <https://forum.ansible.com/t/bug-in-copy-module-for-directory-mode/16054>\
**Category:** Ansible Project\
**Created:** [August 27, 2014, 6:31pm UTC](https://forum.ansible.com/t/bug-in-copy-module-for-directory-mode/16054 "2014-08-27T18:31:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Oliver](https://avatars.discourse-cdn.com/v4/letter/j/97f17d/32.png) [@John\_Oliver](https://forum.ansible.com/u/John_Oliver)\
**Post date:** [August 27, 2014, 6:31pm UTC](https://forum.ansible.com/t/bug-in-copy-module-for-directory-mode/16054/1 "2014-08-27T18:31:59Z")

</div>

This stanza:

- name: Upload ‘macsecurity’ plugin  
copy: src={{git\_src}}/plugins/macsecurity  
dest=/var/www/html/roundcube/plugins/  
mode=0755  
directory\_mode=yes  
group=roundcube

Fails with:

TASK: [roundcube-web | Upload ‘macsecurity’ plugin] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
failed: [jedis-test] =\> {“details”: “invalid literal for int() with base 8: ‘yes’”, “failed”: true, “gid”: 500, “group”: “roundcube”, “md5sum”: “59043bc3af8a7a48361bb2034b28cae8”, “mode”: “0700”, “owner”: “root”, “path”: “/var/www/html/roundcube/plugins/macsecurity/lib”, “secontext”: “unconfined\_u:object\_r:httpd\_sys\_content\_t:s0”, “size”: 4096, “state”: “directory”, “uid”: 0}  
msg: mode needs to be something octalish

The error output just isn’t correct or useful. And the resulting permissions are wrong:

drwx-w----. root roundcube unconfined\_u:object\_r:httpd\_sys\_content\_t:s0 macsecurity

It’s setting the permissions of files inside that directory to 755, which isn’t what I want, and:

[joliver@jedis-test ~]$ sudo ls -lZ /var/www/html/roundcube/plugins/macsecurity/  
-rwxr-xr-x. root roundcube system\_u:object\_r:httpd\_sys\_content\_t:s0 bootstrap\_autoloader.php  
-rwxr-xr-x. root roundcube system\_u:object\_r:httpd\_sys\_content\_t:s0 composer.json  
-rwxr-xr-x. root roundcube system\_u:object\_r:httpd\_sys\_content\_t:s0 config.inc.php  
drwx------. root roundcube unconfined\_u:object\_r:httpd\_sys\_content\_t:s0 lib  
-rwxr-xr-x. root roundcube system\_u:object\_r:httpd\_sys\_content\_t:s0 macsecurity.php  
-rwxr-xr-x. root roundcube system\_u:object\_r:httpd\_sys\_content\_t:s0 phpunit-bootstrap.php  
-rwxr-xr-x. root roundcube system\_u:object\_r:httpd\_sys\_content\_t:s0 phpunit.xml  
-rwxr-xr-x. root roundcube system\_u:object\_r:httpd\_sys\_content\_t:s0 readme.txt

I’ve tried using seuser, but that isn’t reliably applied, and doesn’t make any difference (and nor should it). Once I get all of my files up I’ll set the context in one fell swoop, so I’m not worried about getting that correct during the transfer.

I can’t use ‘synchronize’ as it bombs out complaining there’s no tty, and I have to assume that’ll be required on my targets.

I could zip or tar up the files, but I’m doing it that way I’m doing it because this directory is in git and may change. I suppose I could create an archive every time the playbook is run, but that seems wasteful.

How can I reliably and correctly transfer a directory?

---

<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:** [August 27, 2014, 7:08pm UTC](https://forum.ansible.com/t/bug-in-copy-module-for-directory-mode/16054/2 "2014-08-27T19:08:41Z")

</div>

Directory mode takes something octalish, not a “yes”.

So the error message seems quite right.

The permissions are not set because the module call failed.

---

<div class="post-metadata">

**Author:** ![John\_Oliver](https://avatars.discourse-cdn.com/v4/letter/j/97f17d/32.png) [@John\_Oliver](https://forum.ansible.com/u/John_Oliver)\
**Post date:** [August 27, 2014, 11:05pm UTC](https://forum.ansible.com/t/bug-in-copy-module-for-directory-mode/16054/3 "2014-08-27T23:05:57Z")

</div>

Thanks.

Maybe the docs could be a little clearer on this point? When the default was given as “no”, that made me assume the opposite would be “yes” 🙂 From "When doing a recursive copy set the mode for the directories. ", I inferred that the mode of the parent would be inherited and recursively pushed down.

---

<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:** [August 27, 2014, 11:44pm UTC](https://forum.ansible.com/t/bug-in-copy-module-for-directory-mode/16054/4 "2014-08-27T23:44:40Z")

</div>

Docs say required “no”, not default “no”.

[http://docs.ansible.com/copy\_module.html](http://docs.ansible.com/copy_module.html)
