-
Notifications
You must be signed in to change notification settings - Fork 39
Sync docker context #169
Sync docker context #169
Conversation
882a8b9
to
154b9c5
Compare
154b9c5
to
7b0eed8
Compare
@ssbarnea |
@zhan9san This PR introduces rsync as a requirement. |
Seems like this feature was present before (#51), and was achieved with the copy module rather than the sync module, I'm not sure when and why it was removed though. molecule-docker/molecule_docker/playbooks/create.yml Lines 51 to 57 in abe5e0f
|
That for multiple reasons, among them:
If we are to ever add it back, it would be only based on detection of the required collection and rsync on target host. Shortly, rsync is fast and cool, but is far less portable than copy. |
This commit you mentioned is in The latest commit id in both branch is copy vs synchronizeI think We cannot copy all files in Instead, we can exclude
|
I agree that there are limitations in regards of the copy module for this use case and using the synchronize module would be nice, however as it requires extra dependencies to be installed I think it would be better to stick to the copy module. It is not enough to add ansible.posix, you also need to install rsync. And as rsync is a application and not a python module you can't just simply install it with pip, you would need to accommodate different package names and package managers, etc. which would be out of scope for this driver. The exclude feature is nice, but you can still achieve the same with the copy module by either using a Something like this (untested - written from memory): - name: Copy files for image building
copy:
src: "{{ item.1 }}"
dest: "{{ molecule_ephemeral_directory }}"
mode: "0600"
when: not item.0.pre_build_image | default(false) and not item.0.path
loop: "{{ molecule_yml.platforms | product(_molecule_scenario_files_filtered) | list }}"
vars:
_molecule_scenario_files_filtered: "{{ lookup('fileglob', molecule_scenario_directory ~ `/*', wantlist=true) | reject('search','molecule.yml') | list }}" or - name: Get scenario file list
find:
paths: "{{ molecule_scenario_directory }}"
patterns: "*"
recurse: yes
register: _molecule_scenario_files
- name: Copy files for image building
copy:
src: "{{ item.1 }}"
dest: "{{ molecule_ephemeral_directory }}"
mode: "0600"
when: not item.0.pre_build_image | default(false) and not item.0.path
loop: "{{ molecule_yml.platforms | product(_molecule_scenario_files_filtered) | list }}"
vars:
_molecule_scenario_files_filtered: "{{ _molecule_scenario_files | reject('search','molecule.yml') | list }}" |
You almost convince me. But there has been some existing tools(
IMHO, it is not difficult to install with OS package manager. |
I'm not arguing that rsync isn't a handy tool and in fact I have it installed on most of my servers/workstations. However as this driver is being used in stripped down containers in a lot of CI jobs I feel that depending on rsync in this driver to execute a task that can be done without rsync is not ideal. Previously it was enough to just install the driver but now it requires that you manually install rsync in addition. |
You can make it an opt-in feature, but by default we cannot make use of it. Still, we could have a default that uses rsync if module is installed and rsync is also installed on the image. The idea is to not alter the image during testing without user knowledge as this would nullify the tests for many users. Good part is that we are not against allowing that, but it needs to be a deliberate decision. |
Ensure the docker context are copied to work dir.
Related to #168