In vagrant file.
VAGRANTFILE_API_VERSION = "2"
is the minimum vagrant version.
to set the vm name.
config.vm.name = <somename>
config.vm.box is for setting the image name
vagrant init --minimal
will create a minimal version of vagrant file with many options removed.
to run a shell provisioner.
config.vm.provision "shell" , path: "provision.sh"
In that I might write any shell commands.
apt-get -y update
apt-get -y install nginx
service nginx start
These provisioners will be running during creation of VM but not with reload.
So, we can force it to run when we want using
vagrant provision
To check nginx running.
wget -q0- localhost
to add port forwarding.
config.vm.network "forwarded_port" , guest: 80, host: 8080, id: "nginx"
the localhost:8080 from host will redirect to the VM 80 port.
above id tag is optional and mainly used for identification of ports.
we can add two more inputs to above command as
guest_ip: "X.X.X.X" , host_ip: "X.X.X.X"
this will redirect all ports.
if any conflicts use auto_correct : true in the above command.
For hosting images: vagrantcloud.com
to upload a machine,
vagrant login
vagrant share
vagrant share --ssh
for remote access to the machine.
to connect
vagrant connect --ssh
VAGRANTFILE_API_VERSION = "2"
is the minimum vagrant version.
to set the vm name.
config.vm.name = <somename>
config.vm.box is for setting the image name
vagrant init --minimal
will create a minimal version of vagrant file with many options removed.
to run a shell provisioner.
config.vm.provision "shell" , path: "provision.sh"
In that I might write any shell commands.
apt-get -y update
apt-get -y install nginx
service nginx start
These provisioners will be running during creation of VM but not with reload.
So, we can force it to run when we want using
vagrant provision
To check nginx running.
wget -q0- localhost
to add port forwarding.
config.vm.network "forwarded_port" , guest: 80, host: 8080, id: "nginx"
the localhost:8080 from host will redirect to the VM 80 port.
above id tag is optional and mainly used for identification of ports.
we can add two more inputs to above command as
guest_ip: "X.X.X.X" , host_ip: "X.X.X.X"
this will redirect all ports.
if any conflicts use auto_correct : true in the above command.
For hosting images: vagrantcloud.com
to upload a machine,
vagrant login
vagrant share
vagrant share --ssh
for remote access to the machine.
to connect
vagrant connect --ssh
No comments:
Post a Comment