Vagrant: How can you run scripts on the host through commands in the guest shell?

You can open ports, network files, and there are plugins that allow you to run guest or host commands [shell] during the Vagrant Provisioning process.

What I would like to do is be able (possibly using the bash alias) to execute the command on the Vagrant / VM guest guest system and execute the command on the host, ideally with a passed command line variable.

Example: on my host, I run the Atom editor (the same goes for TextMate, whatever). If I want to work with a shared file in a virtual machine, I have to manually open this file on top of the host, either by opening it directly in the editor or by running the shell command "atom filename".

I want parity, so while inside the virtual machine I can run the "atom file name" and this will transfer the file name "atom $ 1" script outside the VM on the host and open it in my host editor (Atom).


Note. We use Salt for Vagrant Provisioning and NFS for installation, for what it's worth. And, of course, ssh with the key.

Bonus question: do this work with .gitconfig as a merge conflict editor (you just need to work, if the first is possible, right?).

+4
source share
1 answer

, . Vagrant , ​​ Packer . GitHub Vagrant ​​ . , , , - .

, , ...
  • ssh .
  • , /home/vagrant/.ssh .
  • ssh .

...

ssh username@192.168.0.1 "ls -l ~"

, IP- 192.168.0.1 , . .

, , , Vagrant .

+1

Source: https://habr.com/ru/post/1623141/


All Articles