= ("[Website](" + this.website + ")") | = ("[GitHub](" + this.github + ")")
Working directory is shared with VM, accessible under /vagrant.
Commands🔗
1 2 3 4 5 6 7 8 9 10 11 12 | |
Provisioning🔗
https://developer.hashicorp.com/vagrant/docs/provisioning
Happens
- at first
vagrant up, after only if--provisionis set - when running
vagrant provision - calling
vagrant reload --provision
Vagrantfile🔗
Written in ruby language
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
with provisioning script bootstrap.sh. Reload after editing, vagrant reload.
Vagrant also supports linked clones, providing significant savings in disk space, see this article.
Boxes🔗
Package
Package a box for reuse. This didn’t work the way I expected, the packages box didn’t include additional packages I had installed on the parent machine. ^15d863
1 2 3 | |
Repository🔗
Create private Vagrant box repository
- set up nginx on (virtual) machine
bash
# install epel-release and nginx
systemctl enable nginx
systemctl start nginx
mkdir -p /var/www/html/devops/vagrant/boxes
chmod -R 755 /var/www/html/devops/
touch /var/www/html/devops/vagrant/mybox.json
sha1sum /var/www/html/devops/vagrant/boxes/mybox.box
# edit JSON file
# edit nginx config
nginx -t # check nginx config
systemctl restart nginx
Examples🔗
HTML server🔗
In working dir with Vagrantfile, create dir html with file index.html
1 2 3 4 5 6 | |
Create provisioning script bootstrap.sh with content
1 2 3 4 5 6 7 8 | |
assuming Debian family OS, installing Apache and sym-linking synced Vagrant directory and Apache content directory to be served.
Edit Vagrantfile to use provisioning script
1 2 3 4 | |
Start up and verify, for example on VM vagrant@vagrant:~$ wget -qO- 127.0.0.1