<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[The lazy programmer - Medium]]></title>
        <description><![CDATA[My journey from OO to functional programming - Medium]]></description>
        <link>https://medium.com/the-lazy-programmer?source=rss----a4c39d163fee---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>The lazy programmer - Medium</title>
            <link>https://medium.com/the-lazy-programmer?source=rss----a4c39d163fee---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 16:21:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/the-lazy-programmer" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Automating your dev environment setup with vagrant and ansible]]></title>
            <link>https://medium.com/the-lazy-programmer/automating-your-dev-environment-setup-with-vagrant-and-ansible-c6790b3257a0?source=rss----a4c39d163fee---4</link>
            <guid isPermaLink="false">https://medium.com/p/c6790b3257a0</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[clojure]]></category>
            <category><![CDATA[ansible]]></category>
            <category><![CDATA[vagrant]]></category>
            <category><![CDATA[postgres]]></category>
            <dc:creator><![CDATA[Rishi Patel]]></dc:creator>
            <pubDate>Fri, 27 Oct 2017 04:36:16 GMT</pubDate>
            <atom:updated>2017-10-27T04:36:16.532Z</atom:updated>
            <content:encoded><![CDATA[<p>Keeping a automated development environment setup becomes necessary as soon as more than one developer starts working on the project. It helps with on boarding new developer quickly into team and avoids many problems associated with Ad hoc development setup which differs for every developer.</p><p>I will demonstrate how easy it is to standardise your DEV enviornment setup with the help of <a href="https://www.vagrantup.com/">Vagrant</a> and <a href="https://www.ansible.com/">Ansible</a>. I will be using Clojure and postgreSql as an example to explain the setup but it should be easy to adapt it to different tech stack.</p><h3>Vagrant</h3><p>Vagrant is a provisioning tool for virtual machines and provides an easy way to build and manage virtual machine environment. It can provision a virtual machine on VirtualBox, VMware, AWS etc. Vagrant works with the configuration defined in a file called Vagrantfile, which can be commited in the source control. Any member of your team can do just vagrant up to bring up the same dev setup within a few minutes and start developing.</p><p><em>Make sure you have vagrant and </em><a href="https://www.virtualbox.org/"><em>virtualbox</em></a><em> installed on your system before proceeding further.</em></p><p>Create a sample directory or go inside your project folder and enter -</p><pre>vagrant init</pre><p>This will generate a minimal Vagrantfile, which we will modify to suit our need. Please go through this file to see different options we can use to configure our virtual machine. We will be installing ubuntu in this tutorial. Specify the box which we want to download and install. You can find different boxes packaged for Vagrant from official repository at <a href="https://app.vagrantup.com/boxes/search">https://app.vagrantup.com/boxes/search</a></p><pre>config.vm.box = &quot;ubuntu/xenial64&quot; # The OS we will install on VM</pre><pre>#Host only access to VM through this ip<br>config.vm.network &quot;private_network&quot;, ip: &quot;192.168.32.10&quot;</pre><p>Thats it! Now you can run vagrant up to create your virtual machine. First run of this command will take a long time to finish as it will download the box from internet and then install it. Subsequent vagrant up will just start this new machine and finish rather quickly. Once the command finishes you can do vagrant ssh to ssh into your newly created VM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ocxi2usuOE4mb8JACtOqAg.png" /></figure><h4>Checking the networking setup</h4><p>Run a python server in the home directory using this command-</p><pre>python3 -m http.server</pre><p>This will start a minimal http server on port 8000, which you can access only from your host machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gQA2fcgKI-PCi8xNuK28qA.png" /></figure><p>You can see the files available in home directory of your linux machine.</p><h4>Shared Folder</h4><p>By default Vagrant will mount the folder you ran the command from to /vagrant path. In your virtual machine if you go to the /vagrant folder you can see the content of your folder in your host machine. It means you can modify your code on your host machine and changes will be immediately available on your unix machine. You can add any number of shared folder by modifying setting in your Vagrantfile.</p><p>So far we have setup our ubuntu virtual machine. We can ssh to this machine to build and run our code. We can modify our code on host machine and can access any networked traffic from our host machine using a specific ip. Only thing remaining now is that our VM doesnt have necessary software installed to build and run our code. That’s where the ansible comes into play.</p><h3>Ansible</h3><p>From the offical doc -</p><blockquote>Ansible is a radically simple IT automation engine that automates <a href="https://www.ansible.com/provisioning">cloud provisioning</a>, <a href="https://www.ansible.com/configuration-management">configuration management</a>, <a href="https://www.ansible.com/application-deployment">application deployment</a>, <a href="https://www.ansible.com/orchestration">intra-service orchestration</a>, and many other IT needs.</blockquote><p>Ansible provides many built in modules to make these task easier to perform. We define our requirements in a configuration file which is based on <a href="http://docs.ansible.com/ansible/latest/YAMLSyntax.html">YAML Syntax</a> to tell ansible what commands to execute and on which machine.</p><p>Vagrant provides support for many provisioner including chef, puppet, ansible or simple old shell scripts to execute command on the VM. There are two ways to install ansible -</p><ul><li>On host machine — you will have to install ansible on your host(physical machine) machine</li><li>On guest machine — Vagrant can install ansible on the guest machine after creating the VM.</li></ul><p>We will install ansible on the guest machine to avoid installing unnecessary softwares on our host machine.</p><p>Open up your Vagrantfile to configure the ansible-</p><pre>config.vm.provision &quot;ansible_local&quot; do |ansible|<br>    ansible.playbook = &quot;playbook.yml&quot;<br>  end</pre><p>It tells the Vagrant to install the ansible on guest machine. After creation of VM ansible will be installed on it and run using configuration defined in the playbook.yml file. We will create this configuration file to define what software we need to install and how to configure them. For running clojure application we need the following packages to be installed -</p><ol><li>Git (for source code management)</li><li>JAVA (for running our clojure application)</li><li>lein (build management tool for clojure application)</li><li>postgresql (database for our application)</li><li>postgis (postgresql extension, Just for demonstration purpose)</li></ol><p>Apart from installing these softwares, we will create a sample db, db user in postgresql as well. Create a playbook.yml file in your project directory and make sure it matches the content -</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d3c2b2626f1ce7b3a7dacdc1c51eaf90/href">https://medium.com/media/d3c2b2626f1ce7b3a7dacdc1c51eaf90/href</a></iframe><p>Most of these commands here are self explanatory. First we use the apt module to install the softwares on our machine. Java and postgresql are not available in the standard repository, so we add the repository and use the apt module to install these software.</p><h4>PostgreSQL setup explanation</h4><p>This is by far the most complicated step in this tutorial. After installing PostgreSQL and postgis extension, we modify the postgresql config to enable the connection to be made to this database from our host machine. This will allow us to use the pgAdmin installed in our host machine to connect to the database installed on our VM. After that we create a sample db and user and grant the necessary privilages for the user to connect to this database and manage it. At last we enable the postgis extension to be used with this database.</p><p>Now lets try to connect to this database with pgAdmin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*CJltqPAI66m74GpR13C8SA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/1*HVAyyKMZTnYG3vfByf_t0w.png" /></figure><p>As you can see, we can connect to the db from our host machine using pgAdmin.</p><h3>What’s Next?</h3><p>We saw how easy it was to standardise our development environment. Ansible is very powerful to handle many more task than just provisioning However I used the example of clojure with postgresql, Its equally easy to adapt this to any other tech stack.</p><p>As people have already standardise the installation of many softwares, you dont need to reinvent the wheel. You can find readymade recipe at -</p><p><a href="https://galaxy.ansible.com/">Ansible Galaxy</a></p><p>I have added the configuration files for Vagrant and ansible to the github repository. Find them here -</p><p><a href="https://github.com/rishipatel/clojure_postgresql_dev_env_setup">rishipatel/clojure_postgresql_dev_env_setup</a></p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c6790b3257a0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-lazy-programmer/automating-your-dev-environment-setup-with-vagrant-and-ansible-c6790b3257a0">Automating your dev environment setup with vagrant and ansible</a> was originally published in <a href="https://medium.com/the-lazy-programmer">The lazy programmer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>