Single file

Uploading a file from the host machine to the guest machine is quick and easy. We just need to set the provision type as file, the source as the file on our host, and the destination as:

Vagrant.configure("2") do |config|
config.vm.provision "file", source: "secret.env", destination: "secret.env"
end

This will copy our secret.env file into the home folder of our Vagrant guest machine.

If that secret.env file does not exist, Vagrant will throw an error during the startup process:

If the file does exist, then you will see something similar to the following in your console during the startup process:

And after running the vagrant ssh command and connecting to the guest machine, we can run the ls command to list the files within the directory. We will now see the secret.env file:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.183.1