Ansible/Nginx Playbook/Vagrant Setup
From charlesreid1
Contents
Nginx Playbook: Vagrant Setup
This page assumes that we are using Ansible to manage virtual machines created by Vagrant (which is like a Virtual Box wrapper for the command line).
Initializing vagrant machines
The example on the Vagrant page (spinning up a Ubuntu Trusty node) walks through the process. Briefly:
vagrant init ubuntu/trusty64 vagrant up
This will automatically create a Vagrantfile.
You can also set up vagrant to use multiple machines, as in the more complicated Ansible/Full Stack Playbook example.
Remap ports and reload
Next, we want to remap some ports.
We want to arrange the Vagrant machine so that we map the local port 8080 to the vagrant machine's port 80, and map the local port 8443 to the vagrant machine's port 443.
Edit Vagrantfile
The Vagrantfile is a Ruby file that specifies how to start up and set up the Vagrant boxes. We can make modifications to it and ask Vagrant to reload/reboot the virtual machine using the new Vagrantfile. The Vagrantfile should be modified as follows:
VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "ubuntu/trusty64" config.vm.network "forwarded_port", guest: 80, host: 8080 config.vm.network "forwarded_port", guest: 443, host: 8443 end
Now instruct vagrant to reload from the Vagrantfile:
$ vagrant reload ==> default: Forwarding ports... default: 80 => 8080 (adapter 1) default: 443 => 8443 (adapter 1) default: 22 => 2222 (adapter 1)
Flags