Search code examples
vagrantpuppetvagrantfile

Set VM's $PATH via Puppet config.yaml or Vagrantfile?


I would like to add an additional path to my VM's $PATH environment variable through use of my puppet config.yaml or Vagrant file (or some other VM external mechanism that I don't know).

Is this possible? If so, how?


Solution

  • In Vagrant you can easilly provision stuff with a shell script. So first, create a script (in the same folder than your Vagrantfile) that add additional path to $PATH. By exemple, create a file called bootstrap.sh with this content :

    export PATH=$PATH:/foo/bar
    # Or if you want it for all users :
    echo 'PATH=$PATH:/foo/bar' >> /etc/profile
    

    Then in your Vagrantfile, add this line to execute this script when the VM is booted :

    config.vm.provision :shell, path: "bootstrap.sh"