I'm trying to find a simple and reliable way to create a Vagrantfile that: 1. Creates 3 guests, one used to run ansible, and 2 or 3 guests for ansible to manage. 2. Install ssh keys on the guests so that I can use ssh from the ansible guest to control the other guests. 3. To start with, I'd as soon use the "script" provisioner, and maybe the "file" provisioner, to set things up, since I'm only learning ansible.
I'm doing this from a MacOS High Sierra host, and using ubuntu xenial guests. Provider is Virtualbox. The problem is that by default, Vagrant 2.0.1 wants to generate different keys on the fly for each machine; the keys get created into .vagrant/GUEST_NAME/virtualbox/private_key. You can't just copy this file using the file provisioner, though, since the private_key file does not actually exist when the guest is first created. To get around this, I've tried creating a key pair with ssh-keygen. But I don't understand which config.ssh configs to set so that Vagrant will use my key rather than using a dynamic generated key. Just setting subconfig.ssh.private_key_path doesn't work for me; the dynamic key gets installed to the guest, but vagrant uses my key to communicate with it. So vagrant up fails since vagrant can't talk to the host. I've tried to get around this by just adding my key as an additional key, by appending my public key to GUEST:/home/vagrant/.ssh/authorized_keys. This almost works. For some reason, I can't get the file provisioner to copy my keys/custom_key.pub file to the guests. I'm copying from /vagrant/keys/custom_key.pub using the script provisioner. But I also use vagrant-vbguest; this means that when I provision a new host, /vagrant is not always mounted :-( I can supply my current script, but first, is there a better way to do this? Seems to be a lot harder that it should be. -- This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list. GitHub Issues: https://github.com/mitchellh/vagrant/issues IRC: #vagrant on Freenode --- You received this message because you are subscribed to the Google Groups "Vagrant" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/c91ec92b-a349-46bf-9adb-91e8dbad4ae2%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
