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

How to use copy_unarchieve #265

Closed WyriHaximus closed 6 years ago

WyriHaximus commented 6 years ago

Hey I'm currently looking into replacing capistrano with ansistrano, and in the process I want to get rid of using git and composer on the server I'm deploying to in the same update. But when using copy_unarchieve instead of copy I noticed it doesn't create an archive and still uploads file for file. What am I missing or am I just expecting to much magic?

My deploy.yml:

---
- hosts: production
  roles:
    - carlosbuenosvinos.ansistrano-deploy

  vars:
    host_key_checking: false
    ansistrano_deploy_from: "{{ playbook_dir }}"
    ansistrano_deploy_to: "/var/www/wyrimaps.net-static-maps-server"
    ansistrano_version_dir: "releases"
    ansistrano_current_dir: "current"
    ansistrano_current_via: "symlink"
    ansistrano_keep_releases: 10
    ansistrano_deploy_via: copy_unarchive
WyriHaximus commented 6 years ago

It took me some digging and trial and error but I've crafted a solution:

deploy.yml:

---
- hosts: production
  roles:
    - carlosbuenosvinos.ansistrano-deploy

  vars:
    host_key_checking: false
    ansistrano_deploy_from: "{{ playbook_dir }}/metal.tgz"
    ansistrano_deploy_to: "/var/www/wyrimaps.net-static-maps-server"
    ansistrano_version_dir: "releases"
    ansistrano_current_dir: "current"
    ansistrano_current_via: "symlink"
    ansistrano_keep_releases: 10
    ansistrano_deploy_via: copy_unarchive
    ansistrano_before_setup_tasks_file: "{{ playbook_dir }}/before-setup-tasks.yml"
    ansistrano_after_cleanup_tasks_file: "{{ playbook_dir }}/after-cleanup-tasks.yml"

before-setup-tasks.yml:

---
-  name: ANSISTRANO | Create Archive
   delegate_to: localhost
   archive:
     path: "{{ playbook_dir }}/../"
     dest: "{{ playbook_dir }}/metal.tgz"

after-cleanup-tasks.yml:

---
-  name: ANSISTRANO | Remove Archive Locally
   delegate_to: localhost
   file:
     path: "{{ playbook_dir }}/metal.tgz"
     state: absent