get-code-local.yml 686 B

123456789101112131415161718192021222324252627
  1. ---
  2. # Get the latest code
  3. - name: Archive the current Git repository
  4. command: git archive --format tar HEAD
  5. args:
  6. chdir: "{{ local_dir }}"
  7. delegate_to: localhost
  8. register: archive_output
  9. - name: Save output the git repo as an archive
  10. local_action: copy content={{ archive_output.stdout }} dest="{{ local_dir }}/code-archive.tar"
  11. - name: Delete remote code directory if exists
  12. file:
  13. state: absent
  14. path: "{{ remote_code_path }}"
  15. - name: create directory for unarchiving
  16. file:
  17. path: "{{ remote_code_path }}"
  18. state: directory
  19. - name: Extract code into path
  20. unarchive:
  21. src: "{{ local_dir }}/code-archive.tar"
  22. dest: "{{ remote_code_path }}"