So I know you can use the following to run as a different user:
config.ssh.username = "ubuntu"
config.ssh.private_key_path = File.expand_path("../ssh_key", __FILE__)
I'm provisioning the default ubuntu/trusty64 on Virtualbox and if i use the
--provider=aws flag, it will spin up an EC2 instance. I'm also using
Ansible to configure the VM/instance.
The problem I'm running into is using the 'ubuntu' user to be configured.
I was hoping that there is a way to run a shell script prior to vagrant
ssh'ing into the Virtualbox. I tried running this as a shell script:
sudo cp -f /vagrant/ssh_key /home/ubuntu/.ssh/authorized_keys
sudo sed -i '/PasswordAuthentication yes/c\PasswordAuthentication no' /etc/
ssh/sshd_config
sudo service ssh restart
But I believe vagrant will try to ssh first and then run the shell script.
Is there any way around this or do I have to build my own vagrant box and
have this setting in place?
The reason I need to do this is because I'm referencing files in my Ansible
playbook and it doesn't always interpret ~/ with the correct directory. I
could write out the whole path, vagrant's home path is /home/vagrant/ and
the EC2 instance is /home/ubuntu/ and that would look messy. I'm not 100%
sure how I can have conditionals in place (as in Ansible knowing I'm
running this on Virtualbox or AWS).
--
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/d05e2e8f-7631-4b44-b617-ff9d7c830c2c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.