Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

synchronize: quote private_key #21570

Merged
merged 1 commit into from Feb 17, 2017

Conversation

evgeni
Copy link
Contributor

@evgeni evgeni commented Feb 17, 2017

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

synchronize

ANSIBLE VERSION
ansible 2.3.0 (devel a5d34f2ac2) last updated 2017/02/17 12:43:51 (GMT +200)
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
SUMMARY

Assume an inventory that tells Ansible which ssh key to use, and that key has a space:

default ansible_ssh_host=192.168.121.10 ansible_ssh_port=22 ansible_ssh_user='vagrant' ansible_ssh_private_key_file='/home/user/Some Folder/.vagrant/machines/default/libvirt/private_key'

And a simple task to synchronize a file:

    - name: synchronize a file
      synchronize:
        src: /etc/issue
        dest: /tmp/issue2

This will currently fail when passing the key to rsync's --rsh option:

fatal: [default]: FAILED! => {"changed": false, "cmd": "/usr/bin/rsync --delay-updates -F --compress --archive --rsh 'ssh -i /home/user/Some Folder/.vagrant/machines/default/libvirt/private_key -S none -o StrictHostKeyChecking=no -o Port=22' --out-format='<<CHANGED>>%i %n%L' \"/etc/issue\" \"vagrant@192.168.121.10:/tmp/issue2\"", "failed": true, "msg": "Warning: Identity file /home/user/Some not accessible: No such file or directory.\nssh: Could not resolve hostname folder/.vagrant/machines/default/libvirt/private_key: No address associated with hostname\r\nrsync: connection unexpectedly closed (0 bytes received so far) [sender]\nrsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]\n", "rc": 255}

Simply adding double-quotes around the string solves the issue. Using double-quotes as single-quotes are already used for --rsh 'ssh …'.

otherwise rsync will fail when trying to access a key with spaces:

fatal: [default]: FAILED! => {"changed": false, "cmd": "/usr/bin/rsync --delay-updates -F --compress --archive --rsh 'ssh -i /home/user/Some Folder/.vagrant/machines/default/libvirt/private_key -S none -o StrictHostKeyChecking=no -o Port=22' --out-format='<<CHANGED>>%i %n%L' \"/etc/issue\" \"vagrant@192.168.121.10:/tmp/issue2\"", "failed": true, "msg": "Warning: Identity file /home/user/Some not accessible: No such file or directory.\nssh: Could not resolve hostname folder/.vagrant/machines/default/libvirt/private_key: No address associated with hostname\r\nrsync: connection unexpectedly closed (0 bytes received so far) [sender]\nrsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]\n", "rc": 255}
@ansibot ansibot added affects_2.3 This issue/PR affects Ansible v2.3 bugfix_pull_request core_review In order to be merged, this PR must follow the core review workflow. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. labels Feb 17, 2017
@resmo resmo removed the needs_triage Needs a first human triage before being processed. label Feb 17, 2017
@resmo resmo merged commit d3d1aa2 into ansible:devel Feb 17, 2017
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bugfix_pull_request labels Mar 5, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.3 This issue/PR affects Ansible v2.3 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. module This issue/PR relates to a module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants