× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Use a local Virtual Machine with Vagrant and VirtualBox provisioned by my simple Ansible playbook to develop your MEAN stack web apps with no fuss

Victor Kane
May 01, 2015
<p>I whipped up this simple <span style="background-color:rgb(255, 255, 255); color:rgb(102, 102, 102)">Vagrant and Virtualbox based Ansible playbook to set up a MEAN stack (Mongodb, Node + Express suitable for back-end for Angular SPAs) running in a VM, a server running in your local desktop or laptop:</span></p> <p>Grab it at https://github.com/victorkane/simple-mean-vm (star the repo if you think it's cool).</p> <p>Instructions in the README. Let me know how it goes, or if you have any difficulties: https://github.com/victorkane/simple-mean-vm/issues</p> <h2>Ansible playbook - MEAN stack</h2> <p>This Vagrant and Virtualbox based Ansible playbook sets up a MEAN stack (Mongodb, Node + Express suitable for back-end for Angular SPAs).</p> <h3>Instructions</h3> <ul> <li>Install VirtualBox and Vagrant (make sure Vagrant is version 1.6.5 or later)</li> <li>Install Ansible</li> <li>Clone this project to a folder where you keep your VMs</li> <li>On the cammand-line in that folder, type <code>vagrant up</code></li> <li>The process will take a while, on my 4GB RAM MacBook Pro it took about 10 minutes. A large part of that is the provisioning via Ansible of the MEAN components.</li> <li> <p>Associate <code>http://mean01/</code> (or any other name you'd like) with local machine IP specified in the Vagrantfile (192.168.46.100 initially) by including the following line in <code>/etc/hosts</code>:</p> <p>192.168.46.100 mean01</p> </li> <li> <p>Within the guest VM box, if you do your work in, say, <code>/vagrant/dev/project01</code> then in the VM dir <code>./dev/project01</code> you can access the files with your favorite editor or IDE or else edit via ssh remoting.</p> </li> <li>If you create and run a node.js programm on port 3000, you can access it in your browser by pointing it at <code>http://mean01:3000</code>.</li> </ul> <h3>Vagrantfile</h3> <ul> <li>Box used: <a href="https://vagrantcloud.com/ubuntu/boxes/trusty64">Ubuntu 14.04 64-bit (Trusty)</a></li> <li><a href="https://www.virtualbox.org/manual/ch08.html#vboxmanage-modifyvm">Virtualbox settings:</a> <ul> <li>memory 512</li> <li>IP 192.168.46.100</li> </ul> </li> </ul> <h3>Playbook tasks</h3> <ul> <li>Installs build-essential and git packages from Apt.</li> <li>MongoDB installation: <ul> <li>Imports MongoDB's public GPG key.</li> <li>Adds MongoDB's Apt source.</li> <li>Installs MongoDB</li> </ul> </li> <li>Node.js installation: <ul> <li>Sets up <a href="https://github.com/nodesource/distributions">NodeSource</a> for Ubuntu.</li> <li>Installs latest version of Node.js.</li> <li>Installs <a href="http://gruntjs.com/">Grunt</a>.</li> <li>Installs <a href="http://gulpjs.com/">Gulp</a>.</li> </ul> </li> </ul> <h3>References</h3> <ul> <li><a href="https://leanpub.com/ansible-for-devops">Geerling, Jeff, <em>Ansible for DevOps</em></a> <ul> <li><a href="https://github.com/geerlingguy/ansible-for-devops">Ansible for DevOps Examples on GitHub</a></li> </ul> </li> <li><a href="http://adamcod.es/2014/09/23/vagrant-ansible-quickstart-tutorial.html">Vagrant &amp; Ansible Quickstart Tutorial</a></li> <li><a href="https://github.com/dennmart/vagrant-ansible-playbooks/tree/master/mean">Ansible playbook - MEAN stack</a></li> </ul>

Get New Tutorials Delivered to Your Inbox

New tutorials will be sent to your Inbox once a week.

comments powered by Disqus