Question

I want to provide my vagrant box with cuisine, I followed this tutorial but when I try to provide my box with vagrant provision command I get the next error:

[default] Running provisioner: fabric...
[127.0.0.1] Executing task 'provide'
[127.0.0.1] sudo: apt-get update
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/fabric/main.py", line 743, in main
    *args, **kwargs
  File "/usr/local/lib/python2.7/dist-packages/fabric/tasks.py", line 368, in execute
    multiprocessing
  File "/usr/local/lib/python2.7/dist-packages/fabric/tasks.py", line 264, in _execute
    return task.run(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/fabric/tasks.py", line 171, in run
    return self.wrapped(*args, **kwargs)
  File "/home/user/projects/volaris2013/provision.py", line 10, in provide
    prepare_os()
  File "/home/user/projects/volaris2013/provision.py", line 32, in prepare_os
    sudo('apt-get update')
  File "/usr/local/lib/python2.7/dist-packages/fabric/network.py", line 578, in host_prompting_wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/fabric/operations.py", line 1095, in sudo
    stderr=stderr, timeout=timeout, shell_escape=shell_escape,
  File "/usr/local/lib/python2.7/dist-packages/fabric/operations.py", line 909, in _run_command
    channel=default_channel(), command=wrapped_command, pty=pty,
  File "/usr/local/lib/python2.7/dist-packages/fabric/state.py", line 388, in default_channel
    chan = _open_session()
  File "/usr/local/lib/python2.7/dist-packages/fabric/state.py", line 380, in _open_session
    return connections[env.host_string].get_transport().open_session()
  File "/usr/local/lib/python2.7/dist-packages/fabric/network.py", line 118, in __getitem__
    self.connect(key)
  File "/usr/local/lib/python2.7/dist-packages/fabric/network.py", line 110, in connect
    self[key] = connect(user, host, port, sock)
  File "/usr/local/lib/python2.7/dist-packages/fabric/network.py", line 392, in connect
    sock=sock
  File "/usr/local/lib/python2.7/dist-packages/paramiko/client.py", line 342, in connect
    self._auth(username, password, pkey, key_filenames, allow_agent, look_for_keys)
  File "/usr/local/lib/python2.7/dist-packages/paramiko/client.py", line 462, in _auth
    key = pkey_class.from_private_key_file(key_filename, password)
  File "/usr/local/lib/python2.7/dist-packages/paramiko/pkey.py", line 198, in from_private_key_file
    key = cls(filename=filename, password=password)
  File "/usr/local/lib/python2.7/dist-packages/paramiko/rsakey.py", line 51, in __init__
    self._from_private_key_file(filename, password)
  File "/usr/local/lib/python2.7/dist-packages/paramiko/rsakey.py", line 163, in _from_private_key_file
    data = self._read_private_key_file('RSA', filename, password)
  File "/usr/local/lib/python2.7/dist-packages/paramiko/pkey.py", line 279, in _read_private_key_file
    f = open(filename, 'r')
IOError: [Errno 2] No such file or directory: '[/home/user/.vagrant.d/insecure_private_key]'

I think that the error are in the brackets arround the filename, but I don't know how to solve this, I had a similar error in the past, but in fabric tasks, and I solved the problem in my env task.

The versions of packages:

  • Vagrant 1.4.2
  • Fabric==1.8.0
  • cuisine==0.6.5
  • paramiko==1.12.0
  • VirtualBox 4.3.9
Était-ce utile?

La solution

Vagrant (as of 1.4.0) changed to returning the private_key to use from a string to an array. The vagrant-fabric plugin naively assumes it's getting a string and uses #{private_key} directly in its command, which gets written out with the wrapping square brackets.

Here's a fix for lib/vagrant-fabric/provisioner.rb:

private_key = ssh_info[:private_key_path]

#  After https://github.com/mitchellh/vagrant/pull/907 (Vagrant 1.4.0+),
#  private_key_path is an array.
if ! private_key.kind_of?(Array)
  private_key = [private_key]
end
private_key_option = private_key.map { |k| '-i ' + k }.join(' ')

if config.remote == false
  system "#{config.fabric_path} -f #{config.fabfile_path} " +
        "#{private_key_option} --user=#{user} --hosts=#{host} " +
        "--port=#{port} #{config.tasks.join(' ')}"
else

Update: Added pull request: https://github.com/wutali/vagrant-fabric/pull/6

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top