diff --git a/roles/sync/files_sync/defaults/main.yml b/roles/sync/files_sync/defaults/main.yml index 06f6a818..5b65b1fb 100644 --- a/roles/sync/files_sync/defaults/main.yml +++ b/roles/sync/files_sync/defaults/main.yml @@ -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 diff --git a/roles/sync/files_sync/tasks/sync.yml b/roles/sync/files_sync/tasks/sync.yml index cb34430b..d830f11f 100644 --- a/roles/sync/files_sync/tasks/sync.yml +++ b/roles/sync/files_sync/tasks/sync.yml @@ -1,7 +1,7 @@ --- - 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 }}" @@ -9,14 +9,13 @@ 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 }}"