In this tutorial you will learn how to use the Vagrant provision command. Also you will see how to make a correct incremental development.
Code used during this tutorial:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# Vagrant provision command cd ~/vagrant/ubuntu-trusty32/ vi Vagrantfile vi provision-shell/bootstrap.sh #!/bin/bash echo 'Provisioning...' echo 'test' > ~/test.txt vagrant destroy vagrant up --provider virtualbox vagrant ssh sudo ls /root/ sudo poweroff vi provision-shell/bootstrap.sh echo 'test 2' > ~/test-2.txt vagrant up --provider virtualbox # Runs any configured provisioners against the running Vagrant managed machine # Especially useful for incremental development of shell scripts, Chef cookbooks, or Puppet modules vagrant provision vagrant ssh sudo ls /root/ exit # "vagrant provision" is useful for incremental development but if you remove code you can get in some trouble vi provision-shell/bootstrap.sh #echo 'test 2' > ~/test-2.txt vagrant provision vagrant ssh sudo ls /root/ exit # Solution vagrant destroy -f vagrant up --provider virtualbox vagrant ssh sudo ls /root/ # Useful links https://docs.vagrantup.com/v2/cli/provision.html |
Useful links:
https://docs.vagrantup.com/v2/cli/provision.html