Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

project_copy_folders are always copied to the root #1026

Closed
5 of 6 tasks
mockey opened this issue Nov 3, 2018 · 6 comments · Fixed by #1364
Closed
5 of 6 tasks

project_copy_folders are always copied to the root #1026

mockey opened this issue Nov 3, 2018 · 6 comments · Fixed by #1364

Comments

@mockey
Copy link
Contributor

mockey commented Nov 3, 2018

Bug report

Replace any X with your information.


What is the current behavior?

When you add a folder to project_copy_folders like - web/app/languages it is copied to root after the deploy. Makes sense if you look at the code:
cp -rp {{ deploy_helper.current_path }}/{{ item.item }} {{ deploy_helper.new_release_path }}

What is the expected or desired behavior?

The folder should be copied to where it was. I guess:
cp -rp {{ deploy_helper.current_path }}/{{ item.item }} {{ deploy_helper.new_release_path }}/{{ item.item }}
would do.


Please provide steps to reproduce, including full log output:

Add a non-root folder to project_copy_folders and see where it ends. vendor works beause it is in root.

Please describe your local environment:

Ansible version: 2.7.1

OS: Linux Mint 17

Vagrant version: 2.2.0

Where did the bug happen? Development or remote servers?

Remote (after deploy)

Is there a related Discourse thread or were any utilized (please link them)?

Just posted it here:
https://discourse.roots.io/t/adding-wp-language-files-on-deploy/9212/26

@swalkinshaw
Copy link
Member

This sounds like a good improvement. Want to do a PR for it?

@mockey
Copy link
Contributor Author

mockey commented Nov 11, 2018

Sure, but I'm wondering: Wouldn't it be better to use the synchronize (or copy) ansible module here? Or is there a special reason for using cp -rp?
The code above with cp -rp doesn't work if the target folder already exists. E.g. when you have an empty web/app/languages in your deploy, you end up with web/app/languages/languages.
I think synchronize or copy would work then if project_copy_folders ends with a /.

@swalkinshaw
Copy link
Member

I don't remember any great reason. Could just be an oversight so it's worth trying out.

@mockey
Copy link
Contributor Author

mockey commented Nov 12, 2018

I'm not an ansible expert. The docs (https://docs.ansible.com/ansible/latest/modules/copy_module.html) say that synchronize (based on rsync) should be preferred to copy for folders with lots of files.
I see trellis uses copy in a couple of places, synchronize is only used in the build-before deploy-hook. What do you think?

@swalkinshaw
Copy link
Member

Oh I remember now. In the past the copy module was for local -> remote. So often we'd use cp via command to just do a copy all on the remote machine.

copy only got the remote_src option in 2.0 and synchronize needs delegate_to: "{{ inventory_hostname }}" or something.

That warning about copy not scaling is because it assumes we're dealing with local -> remote (so copying over the network).

So basically, I'm in favour of using whatever makes it the easiest 😄

@mockey
Copy link
Contributor Author

mockey commented Nov 12, 2018

I see. I wasn't aware of that local -> remote scheme. But that makes sense for ansible of course. I think I'll try to get copy working then. It might be useful to be able to copy something to an existing folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants