First, we want to create a new project, so let's create a new folder called lamp_stack
and initialize a new precise64
Vagrant project within it by executing the following commands:
mkdir lamp_stack cd lamp_stack vagrant init precise64
Tip
You will need to have the Ubuntu precise64
box installed for the previous command to work. For more information, see Chapter 2, Managing Vagrant Boxes and Projects.
We want to forward port 80 from our guest machine to port 8080 on our host machine to make it easier to access the web project we have within the virtual machine. In order to achieve this, let's add the following line to our Vagrant file. Some versions of Vagrant will automatically include this line but commented it out, so we may just need to remove the comment (# character from the start of the line):
config.vm.network :forwarded_port, guest: 80, host: 8080
Before we run our Puppet provisioner to install our LAMP stack, we should instruct Vagrant to run the apt-get update
command on the virtual machine. Without this, it isn't always possible to install new packages:
config.vm.provision :shell, :inline => "apt-get update"
As we will be putting our Puppet modules and manifests in a provision folder, we need to configure Vagrant to use the correct folders for our Puppet manifests and modules as well as the default manifest file. Adding the following to our Vagrant file will do this for us:
config.vm.provision :puppet do |puppet| puppet.manifests_path = "provision/manifests" puppet.module_path = "provision/modules" puppet.manifest_file = "default.pp" end