This statement defines the name of the playbook that should be used to provision our box. Here, let's focus on the statement aybook = "lamp.yml". Add the following lines before the end statement in your Vagrantfile to set Ansible as the provisioning provider:Ĭonfig.vm.provision :ansible do |ansible| The next step is to set Ansible as our provisioning provider for the Vagrant box. This will map the port 80 of our Vagrant ox to port 8080 off our host machine. To setup port forwarding, add the following line just before the end statement in Vagrantfile:Ĭonfig.vm.network "forwarded_port", guest: 80, host: 8080 Now, let's setup port forwarding for so that after everything is setup and running, we can test our server. The following line lists the base box which our configuration uses. Let's open this file and modify it according to our needs. This will initialize the Vagrant box and create a file named Vagrantfile with some pre-configured variables. Issue the following command to initialize the box: For our tutorial, we will be initializing our box with Ubuntu 14.04 as base. Our box will be a simple one which will run Ubuntu 14.04 as its base system over which we will be running Apache 2, MySQL and PHP5.Ī Vagrant box can be initialized using the vagrant init command. Let's move on to initializing our box.īefore we move on to create our box, let me explain what we will be aiming for. ![]() To create this directory and make it as our current working directory, issue the following command: So, let's start by creating a new directory which will store our files related to the Vagrant box. Setting up the Vagrant boxĮditor's note: If you want to run get started with Vagrant to provision or build containers using Red Hat Enterprise Linux with just a few clicks, check out the Red Hat Container Development Kit.īefore we use Ansible to provision our box, we need to create one. Now, since we are done with setting up the per-requisites, lets move on and create our first Vagrant box which we will soon configure using Ansible. The need for installing VirtualBox is because, Vagrant doesn't provide functionality to host your virtual machines but rather depends on 3rd party providers such as VirtualBox, VMWare, etc. ![]() As you have noticed, alongwith Vagrant, we are also installing VirtualBox. The above command will install Vagrant on your host system. To install Vagrant, execute the following command on your host system, Now, since we are done installing Ansible, let's install Vagrant. If you get a screen which looks somewhat similar to the one below, Ansible installed just fine for you. To test if Ansible has been properly installed, execute the following command: ![]() This will automatically Ansible and the required dependencies on your host system. On your host machine, execute the following command to install Ansible. The tutorial requires Ansible and Vagrant to be installed on the host machine. ![]() Setting up the pre-requisitesįor configuring Vagrant boxes using Ansible, we will require a few things to be setup beforehand. So, let's see how we can do this.įor this tutorial, I am using Fedora 24 as my host system and Ubuntu 14.04 (Trusty) as my Vagrant box.Įditor's note: If you want to run get started with Vagrant to provision or build containers using Red Hat Enterprise Linux with just a few clicks, check out the Red Hat Container Development Kit. Using Ansible, we can automate the task of provisioning the Vagrant boxes with our development packages. We can use these boxes to distribute the development environment which the other team members can use to work on the projects. So, what exactly is a Vagrant box? In simple terms, we can think of a vagrant box as a virtual machine prepackaged with the development tools we require to run our development environment. From automating the task of configuration management to provisioning and managing containers for application deployments, Ansible makes it easy. In this article, we will see how we can use Ansible to provision Vagrant boxes. Ansible serves as a great tool for those system administrators who are trying to automate the task of system administration.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |