Vagrant / Ansible config: change to /vagrant on login

Apr 16, 2015 linux
This post is more than 18 months old. Since technology changes too rapidly, this content may be out of date (but that's not always the case). Please remember to verify any technical or programming information with the current release.

While those familiar with the specifics of linux and bash are probably very familiar with the various login sequence files, this might help someone!

If you’d like to save some keystrokes after a vagrant ssh - you might want to add this line to your ansible config. This will automatically change directory to the /vagrant folder when you log in.

  - name: Create redirect for bash login
      line="cd /vagrant" 

This simply puts a .bash_login file in the vagrant user home directory with one line: to change to the /vagrant directory.

You could make this even more dynamic by making the mapped folder root in vagrant a variable, and then pass that to the ansible extra_vars if you wanted.

Go to All Posts