Skip to content
This repository was archived by the owner on Oct 8, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions roles/sync/files_sync/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
files_sync:
directories:
- source:
# Location of the files to sync from.
# Location of the files to sync from. DO NOT INCLUDE TRAILING SLASH!
files_dir: "/home/{{ deploy_user }}/shared/{{ project_name }}_prod/assets/{{ project_name }}_prod_default_public_files"
# Host that can connect to the database.
# Host that contains source files.
host: "localhost"
# For "rolling builds", so we can compute the database name.
# Location on deploy server where source files get copied to first. NO TRAILING SLASH.
temp_dir: "/tmp"
# Used to create directory in /tmp.
build_id: mybuildprod
target:
# Location of the files to sync to.
# Location of the files to sync to. DO NOT INCLUDE TRAILING SLASH!
files_dir: "/home/{{ deploy_user }}/shared/{{ project_name }}_dev/assets/{{ project_name }}_dev_default_public_files"
build_id: mybuilddev
11 changes: 5 additions & 6 deletions roles/sync/files_sync/tasks/sync.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
---
- name: Create a temporary directory for source files on localhost.
ansible.builtin.file:
path: "/tmp/{{ files.source.build_id }}"
path: "{{ files.source.temp_dir }}/{{ files.source.build_id }}"
state: directory
owner: "{{ deploy_user }}"
group: "{{ deploy_user }}"
delegate_to: localhost
run_once: true

- name: Copy the source files onto the deploy server.
ansible.posix.synchronize:
mode: pull
src: "{{ files.source.files_dir }}"
dest: "/tmp/{{ files.source.build_id }}"
ansible.builtin.command:
cmd: "rsync -e 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' -aHPv {{ files.source.host }}:{{ files.source.files_dir }}/ {{ files.source.temp_dir }}/{{ files.source.build_id }}/"
delegate_to: "localhost"

- name: Copy the source files from the deploy server onto the destination server.
ansible.builtin.copy:
src: "/tmp/{{ files.source.build_id }}"
src: "{{ files.source.temp_dir }}/{{ files.source.build_id }}"
dest: "{{ files.target.files_dir }}"
owner: "{{ deploy_user }}"
group: "{{ deploy_user }}"