{"action":"created","issue":{"url":"https://api.github.com/repos/metacloud/molecule/issues/1323","repository_url":"https://api.github.com/repos/metacloud/molecule","labels_url":"https://api.github.com/repos/metacloud/molecule/issues/1323/labels{/name}","comments_url":"https://api.github.com/repos/metacloud/molecule/issues/1323/comments","events_url":"https://api.github.com/repos/metacloud/molecule/issues/1323/events","html_url":"https://github.com/metacloud/molecule/issues/1323","id":327312934,"number":1323,"title":"The ansible synchronize module is not usable from the Alpine based retr0h/molecule container","user":{"login":"themr0c","id":243761,"avatar_url":"https://avatars2.githubusercontent.com/u/243761?v=4","gravatar_id":"","url":"https://api.github.com/users/themr0c","html_url":"https://github.com/themr0c","followers_url":"https://api.github.com/users/themr0c/followers","following_url":"https://api.github.com/users/themr0c/following{/other_user}","gists_url":"https://api.github.com/users/themr0c/gists{/gist_id}","starred_url":"https://api.github.com/users/themr0c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/themr0c/subscriptions","organizations_url":"https://api.github.com/users/themr0c/orgs","repos_url":"https://api.github.com/users/themr0c/repos","events_url":"https://api.github.com/users/themr0c/events{/privacy}","received_events_url":"https://api.github.com/users/themr0c/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-29T13:08:09Z","updated_at":"2018-05-30T00:21:49Z","closed_at":null,"author_association":"NONE","body":"# Issue Type\r\n\r\n- Bug report\r\n\r\n# Molecule and Ansible details\r\n\r\nusing retr0h/molecule:latest\r\n\r\n# Desired Behavior\r\n\r\nI wish to use the synchronize module for a task in a role, and test its behaviour using molecule container, as stated in the docker in docker video.\r\n\r\n\r\n\r\n# Actual Behaviour (Bug report only)\r\n\r\nLet's create an example role:\r\n\r\n```\r\nmolecule  init role -r test_sync\r\n```\r\n\r\nModify tasks/main.yml:\r\n\r\n```\r\n- name: synchronize\r\n  synchronize:\r\n    dest: /tmp/\r\n    src: \"{{ role_path }}/tasks/main.yml\"\r\n```\r\nThen run molecule test from the retr0h/molecule:latest container:\r\n\r\n```\r\ndocker run --rm -it -v $(pwd):/tmp/$(basename \"${PWD}\") -v /var/run/docker.sock:/var/run/docker.sock -w /tmp/$(basename \"${PWD}\") retr0h/molecule:latest sudo molecule --debug test\r\n```\r\n\r\nmolecule test will fail on following:\r\n\r\n```\r\nfatal: [instance]: FAILED! => {\"changed\": false, \"msg\": \"Failed to find required executable rsync in paths: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\"}\r\n```\r\n\r\nLet's circumvent limitations of current container with following molecule/default/prepare.yml:\r\n\r\n```\r\n---\r\n- name: Prepare\r\n  hosts: localhost\r\n  gather_facts: true\r\n  tasks:\r\n    - name: \"apk | we need rsync to use synchronize module\"\r\n      delegate_to: localhost\r\n      apk:\r\n        name: rsync\r\n        state: present\r\n        update_cache: true\r\n      when:\r\n        - ansible_os_family == 'Alpine'\r\n```\r\n\r\nNow we have another error:\r\n\r\n```\r\nfatal: [instance]: FAILED! => {\"changed\": false, \"msg\": \"Failed to find required executable ssh in paths: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\"}\r\n```\r\n\r\nLet's enhance the prepare.yml:\r\n\r\n```\r\n---\r\n- name: Prepare\r\n  hosts: localhost\r\n  gather_facts: true\r\n  tasks:\r\n    - name: \"apk | we need rsync and openssh to use synchronize module\"\r\n      delegate_to: localhost\r\n      apk:\r\n        name:\r\n          - openssh\r\n          - rsync\r\n        state: present\r\n        update_cache: true\r\n      when:\r\n        - ansible_os_family == 'Alpine'\r\n```\r\n\r\nNow we get stuck:\r\n\r\n```\r\n fatal: [instance]: FAILED! => {\"changed\": false, \"cmd\": \"/usr/bin/rsync --delay-updates -F --compress --archive --rsh=/usr/bin/ssh -S none -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null --blocking-io --rsh=/usr/local/bin/docker exec -i --out-format=<<CHANGED>>%i %n%L /tmp/test_sync/tasks/main.yml instance:/tmp/\", \"msg\": \"protocol version mismatch -- is your shell clean?\\n(see the rsync man page for an explanation)\\nrsync error: protocol incompatibility (code 2) at compat.c(178) [sender=3.1.3]\\n\", \"rc\": 2}\r\n```\r\nAnd with more debug output:\r\n\r\n```\r\n    TASK [test_sync : synchronize] *************************************************\r\n    task path: /tmp/test_sync/tasks/main.yml:4\r\n    Using module file /usr/lib/python2.7/site-packages/ansible/modules/files/synchronize.py\r\n    <instance> ESTABLISH LOCAL CONNECTION FOR USER: root\r\n    <instance> EXEC /bin/sh -c 'echo ~ && sleep 0'\r\n    <instance> EXEC /bin/sh -c '( umask 77 && mkdir -p \"` echo /root/.ansible/tmp/ansible-tmp-1527598418.97-27284770950566 `\" && echo ansible-tmp-1527598418.97-27284770950566=\"` echo /root/.ansible/tmp/ansible-tmp-1527598418.97-27284770950566 `\" ) && sleep 0'\r\n    <instance> PUT /root/.ansible/tmp/ansible-local-356Mv6Djn/tmp7gWMQv TO /root/.ansible/tmp/ansible-tmp-1527598418.97-27284770950566/synchronize.py\r\n    <instance> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1527598418.97-27284770950566/ /root/.ansible/tmp/ansible-tmp-1527598418.97-27284770950566/synchronize.py && sleep 0'\r\n    <instance> EXEC /bin/sh -c '/usr/bin/python2 /root/.ansible/tmp/ansible-tmp-1527598418.97-27284770950566/synchronize.py && sleep 0'\r\n    The full traceback is:\r\n      File \"/tmp/ansible_r_S3vu/ansible_module_synchronize.py\", line 312, in <module>\r\n        from shlex import quote as shlex_quote\r\n    \r\n    fatal: [instance]: FAILED! => {\r\n        \"changed\": false, \r\n        \"cmd\": \"/usr/bin/rsync --delay-updates -F --compress --archive --rsh=/usr/bin/ssh -S none -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null --blocking-io --rsh=/usr/local/bin/docker exec -i --out-format=<<CHANGED>>%i %n%L /tmp/test_sync/tasks/main.yml instance:/tmp/\", \r\n        \"invocation\": {\r\n            \"module_args\": {\r\n                \"_local_rsync_path\": \"rsync\", \r\n                \"_substitute_controller\": false, \r\n                \"archive\": true, \r\n                \"checksum\": false, \r\n                \"compress\": true, \r\n                \"copy_links\": false, \r\n                \"delete\": false, \r\n                \"dest\": \"instance:/tmp/\", \r\n                \"dest_port\": null, \r\n                \"dirs\": false, \r\n                \"existing_only\": false, \r\n                \"group\": null, \r\n                \"link_dest\": null, \r\n                \"links\": null, \r\n                \"mode\": \"push\", \r\n                \"owner\": null, \r\n                \"partial\": false, \r\n                \"perms\": null, \r\n                \"private_key\": null, \r\n                \"recursive\": null, \r\n                \"rsync_opts\": [\r\n                    \"--blocking-io\", \r\n                    \"--rsh=/usr/local/bin/docker exec -i\"\r\n                ], \r\n                \"rsync_path\": null, \r\n                \"rsync_timeout\": 0, \r\n                \"set_remote_user\": true, \r\n                \"src\": \"/tmp/test_sync/tasks/main.yml\", \r\n                \"ssh_args\": null, \r\n                \"times\": null, \r\n                \"verify_host\": false\r\n            }\r\n        }, \r\n        \"msg\": \"protocol version mismatch -- is your shell clean?\\n(see the rsync man page for an explanation)\\nrsync error: protocol incompatibility (code 2) at compat.c(178) [sender=3.1.3]\\n\", \r\n        \"rc\": 2\r\n    }\r\n```\r\n\r\nI genuinely though it would be as simple as adding rsync and openssh in the Dockerfile, but apparently I am wrong. \r\n\r\nNow it's time to ask help :/\r\n"},"comment":{"url":"https://api.github.com/repos/metacloud/molecule/issues/comments/392990803","html_url":"https://github.com/metacloud/molecule/issues/1323#issuecomment-392990803","issue_url":"https://api.github.com/repos/metacloud/molecule/issues/1323","id":392990803,"user":{"login":"retr0h","id":9895,"avatar_url":"https://avatars1.githubusercontent.com/u/9895?v=4","gravatar_id":"","url":"https://api.github.com/users/retr0h","html_url":"https://github.com/retr0h","followers_url":"https://api.github.com/users/retr0h/followers","following_url":"https://api.github.com/users/retr0h/following{/other_user}","gists_url":"https://api.github.com/users/retr0h/gists{/gist_id}","starred_url":"https://api.github.com/users/retr0h/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/retr0h/subscriptions","organizations_url":"https://api.github.com/users/retr0h/orgs","repos_url":"https://api.github.com/users/retr0h/repos","events_url":"https://api.github.com/users/retr0h/events{/privacy}","received_events_url":"https://api.github.com/users/retr0h/received_events","type":"User","site_admin":false},"created_at":"2018-05-30T00:21:49Z","updated_at":"2018-05-30T00:21:49Z","author_association":"MEMBER","body":"Looks like rsync is required for syncronize.  You could build a container off retr0h/molecule and add rsync to the container."}}
{"actor":{"display_login":"retr0h"}}