ansistrano / deploy

Ansible role to deploy scripting applications like PHP, Python, Ruby, etc. in a capistrano style
https://ansistrano.com
MIT License
2.37k stars 343 forks source link

Add rsync_unarchive update-code option #289

Closed Pegasuz closed 5 years ago

Pegasuz commented 6 years ago

This adds an option to deploy a pre-build package of your code to the remote servers using rsync, unarchive it, and use it to deploy the application.

Option name: ansistrano_deploy_via: "rsync_unarchive"

To specify the deploy package: ansistrano_deploy_from: "{{ playbook_dir }}/../deploy_package.tar.gz"

This option is needed because we use a CI tool to generate all dependencies for our project, package everything and deploy this package.

This makes it very useful to re-use the deploy packages.

carlosbuenosvinos commented 6 years ago

Hi @Pegasuz, thanks for your contribution. It would be great if you can add some tests. Do you think it's feasible?

carlosbuenosvinos commented 6 years ago

After reviewing the code more in detail, I think the method should be just unarchive (ansistrano goes to find a file in the existing server and unarchives it). How the file is put in the server is something easy to handle as a hook task. What do you think? Also I will like to hear from @ricardclau 😄

membrive commented 6 years ago

What do you mean with a hook task?

You could also unpack a file after copying it from the local machine, using the default remote_src: no option of the unarchive Ansible module. What do you think?

carlosbuenosvinos commented 6 years ago

Hi @membrive. You can use the "ansistrano_before_update_code_tasks_file" hook to upload the file to your server. Then a new "unarchive" method to deploy from a zip file in the same server is what should be created.

carlosbuenosvinos commented 6 years ago

Hi @Pegasuz and @membrive!

I see two options here:

  1. What about using the existign "copy_unarchive" method we have? https://github.com/ansistrano/deploy/blob/master/tasks/update-code/copy_unarchive.yml
  2. Put the archived file in the server with a hook (or previous at running ansistrano) and then using "download_unarchive.yml" using a "file://" protocol. Example:

(from http://docs.ansible.com/ansible/latest/get_url_module.html)

Thanks for your time contributing and commenting 👍

membrive commented 6 years ago

Hi @carlosbuenosvinos, thanks for your answer.

I like option 1 over 2, since it can be used without needing an additional file for the hook.

I will try it this week. Thank you!

carlosbuenosvinos commented 6 years ago

Great @membrive! Let me know how it goes!

carlosbuenosvinos commented 6 years ago

Hi @membrive and @Pegasuz! Any update about the proposed approach? Can be close this PR? Thanks!

membrive commented 6 years ago

@carlosbuenosvinos sorry, I haven't had time to try it, but I'll do it as soon as possible.

din-gi commented 5 years ago

What's going on with this PR? I use CircleCI and doing rsync will just take tons of time without archiving before. Thanks!

ricardclau commented 5 years ago

Closing as this can be achieved with a pre hook and using existing strategies such as donwload_unarchive or copy_unarchive