![]() ![]() If you have worked with bash you might have used heredoc. config.vm.provision "shell" do |cmd|Ĭmd.inline = "echo Welcome to Linuxshelltips" This is the same as the previous one-line definition. You can also use block syntax which offers more readability. $ vagrant reload -provision # Restarting the VM Shell Provisioner $ vagrant up -provision # Starting the VM Take a look at the below image, I added the shell provisioner to the Vagrantfile and started my virtual machine and it tells me to use the -provision flag since this is not the first time I am booting this VM. Provisioner normally runs only when you execute “ vagrant up” for the first time. config.vm.provision "shell", inline: "echo Welcome to linuxshelltips"īefore running any provisioner there is an important point to be noted. Go ahead and modify the Vagrantfile and add the above line. After defining the shell provisioner you have to pass inline and command as a key-value pair. The below example shows how to use an inline script. There are many ways to use an inline script. In the inline script, you will pass the shell commands inside the Vagrantfile. How to Work with Inline Script in Vagrant There are two ways you can execute shell commands in vagrant. ![]() To use shell provisioner you have to pass shell as the argument to vm.provision method. Shell provisioners allow you to execute shell commands in your vagrant machine. How to Use a Shell Provisioner in Vagrant This article will see two of the provisioner’s File and Shell that you may use regularly when you are deploying new virtual machines. You can use any of these tools and automate your virtual machine deployment workflow. Vagrant support provisioners like file, shell, ansible, puppet, and salt stack. Provisioners are tools that allow you to automate your workflow when you are booting up a virtual machine. ![]()
0 Comments
Leave a Reply. |