{"id":18803,"date":"2016-01-03T03:01:38","date_gmt":"2016-01-02T17:01:38","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=18803"},"modified":"2016-01-04T14:48:23","modified_gmt":"2016-01-04T04:48:23","slug":"vagrant-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/vagrant-primer-tutorial\/","title":{"rendered":"Vagrant Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/vagrant_primer.jpg\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Vagrant Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/Mac\/vagrant_primer.jpg\" title=\"Vagrant Primer Tutorial\"  style=\"float:left;\"   \/><\/a><p class=\"wp-caption-text\">Vagrant Primer Tutorial<\/p><\/div>\n<p>In understanding what is out there on the net, tend to want to form relationships in my mind, between applications.<\/p>\n<p>So here&#8217;s a good one &#8230; <a target=_blank title='VirtualBox by Oracle' href='https:\/\/www.virtualbox.org\/'>VirtualBox<\/a> with Vagrant &#8230; or perhaps &#8230; <a target=_blank title='VirtualMachine by VMWare' href='https:\/\/www.vmware.com\/au'>VirtualMachine<\/a> with Vagrant.<\/p>\n<p>So here&#8217;s another one that&#8217;ll knock your socks off (and you&#8217;ll want to read after\/before\/same time\/while having corn flakes as today (to get it all in context, if this is new knowledge)) &#8230; <a target=_blank title='Ansible OpenSource project' href='https:\/\/github.com\/ansible\/ansible'>Ansible<\/a> with Vagrant, that we talked about yesterday with <a title='Ansible Hello World Primer Tutorial' href='#ahwpt'>Ansible Hello World Primer Tutorial<\/a> as shown below.  As you read it, take note of the title of the book we recommend &#8230; &#8220;Ansible Up and Running&#8221; by Lorin Hochstein &#8230; the word &#8220;up&#8221; is bound to be in the list of a  deployer&#8217;s favourite words, and is critical to all &#8220;Vagrant&#8221; talk as its favourite command (and its &#8220;nirvana&#8221; (if successful), and is slow the first time (when &#8220;vagrant up&#8221; is often preceded by an initialization vagrant command such as &#8220;vagrant init ubuntu\/trusty32&#8221;) with a project on an individual programmer&#8217;s system, but fast from then on for that programmer &#8220;revisiting&#8221;, so that on multiple projects they&#8217;re zooming (ie. cd&#8217;ing) around to places and going &#8220;vagrant up&#8221; <font size=3>vagrant up<\/font> <font size=2>vagrant up<\/font> <font size=1>vagrant up<\/font>) is &#8230;<br \/>\n<code>vagrant up<\/code><br \/>\n &#8230; and for today&#8217;s book recommendation &#8230; &#8220;Vagrant Up and Running&#8221; by Mitchell Hashimoto &#8230; fancy that?!\n<\/p>\n<p>So what&#8217;s <a target=_blank title='Vagrant' href='http:\/\/www.vagrantup.com\/'>Vagrant<\/a>?  And why is it so friendly?<\/p>\n<p>Can try to answer the first now, but the second one relates to early times spent with Caspar the Ghost &#8230; but we digress.<\/p>\n<p>To quote the Vagrant landing page &#8230;<\/p>\n<blockquote><p>\nCreate and configure lightweight, reproducible, and portable development environments.\n<\/p><\/blockquote>\n<p>What we understand in layperson&#8217;s terms is that if a client plonks a &#8220;system&#8221; on your doorstep and says any of &#8230;<\/p>\n<ol>\n<li>&#8220;Fix this.&#8221;<\/li>\n<li>&#8220;Maintain this.&#8221;<\/li>\n<li>&#8220;Make it do this, now (awwwwwwwright &#8230; after lunch, then).&#8221;<\/li>\n<\/ol>\n<p> &#8230; Vagrant may interface to an IDE like <a target=_blank title='PHPStorm IDE' href='https:\/\/www.jetbrains.com\/phpstorm\/'>PHPStorm<\/a> (which we&#8217;ll talk about soon) or use Git (or GitHub) and\/or Composer in a Work Flow helping a group of team leaders and dbas and analysts and programmers achieve this by &#8230;<\/p>\n<ul>\n<li>simulating the whole system<\/li>\n<li>modelling the whole system<\/li>\n<li>changing and modifying the resultant model, to check things improve, and still work, hopefully<\/li>\n<li>deploy this model back onto the reality, for the client to model a broad grin, hopefully<\/li>\n<\/ul>\n<p>Without this Vagrant and VirtualDisk (or VMWare) relationship, the job can be done, but you often find the (different) environment (between the programmer environments and the client environment) causes problems during the deployment phase, whereas using these products helps mitigate against these issues.  Comprehendo?<\/p>\n<hr>\n<p id='ahwpt'>Previous relevant <a target=_blank title='Ansible Hello World Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/ansible-hello-world-primer-tutorial'>Ansible Hello World Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/Ansible\/ansible-99of.jpg\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Ansible Hello World Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/Mac\/Ansible\/ansible-99of.jpg\" title=\"Ansible Hello World Primer Tutorial\"  style=\"float:left;\" id='iaoft' onmouseover=\" this.src=this.src.replace('-51of.jpg','-61of.xjpg').replace('-61of.jpg','-71of.xjpg').replace('-71of.jpg','-92of.xjpg').replace('-92of.jpg','-93of.xjpg').replace('-93of.jpg','-94of.xjpg').replace('-94of.jpg','-97of.xjpg').replace('-97of.jpg','-99of.xjpg').replace('-99of.jpg','-51of.xjpg').replace('.xjpg','.jpg');  \"  \/><\/a><p class=\"wp-caption-text\">Ansible Hello World Primer Tutorial<\/p><\/div>\n<p>The role of a programmer is expanding into deployment with software tools such as <a target=_blank title='Ansible OpenSource project' href='https:\/\/github.com\/ansible\/ansible'>Ansible<\/a>, because it has the capability of making the piloting of automation systems &#8220;approachable&#8221; as an &#8220;art&#8221;.<\/p>\n<p>Why would you want to &#8220;pilot an automation system&#8221;?  Well, to see the whole picture, when you (are part of a team that) are given a software project of improving a &#8220;system&#8221;, wouldn&#8217;t it be great to &#8230;<\/p>\n<ul>\n<li>model that customer system at a snapshot of time<\/li>\n<li>be able to work and test on that model away from the customer environment until satisfaction<\/li>\n<li>after changes are tested to satisfaction, redeploy to the customer&#8217;s live system via software changes made to the model, and perhaps to data and configuration settings as well<\/li>\n<\/ul>\n<p>?  We think it sounds very good, especially with Ansible helping out with that modelling, because a lot of the doubt in a programmer&#8217;s head when working away from a customer site&#8217;s environment (back at their office, perhaps) on a project that is going to be deployed back at the customer is that what they are seeing working, may not work when taken back and deployed onto the customer site&#8217;s environment again.  The work methods above help to mitigate that, and Ansible really helps with the deployment aspects to the whole job, leaving programmers more time to get back to what they enjoy the most, methinks &#8230; programming and unit testing.<\/p>\n<p>Without Ansible, achieving a project with new (never before used) software tools required, involves programmers working out the <i>configuration management<\/i> aspects to the job via Search Engine Searches (with a lot of &#8220;Adding to Favourites&#8221;) and\/or the recalling of online documents (often from the OpenSource world), and trialling configurations, hopefully combined with personalized accompanying documentation.   Employing Ansible into the planning may still involve this initial effort, but should never happen again, because what you are left with will be an Ansible approach capturing knowledge that has a far better chance of staying up to date.<\/p>\n<p>Ansible is pretty obviously most advantageous in complex deployment scenarios, but it can be applied to the one server (and we are talking Linux or Unix with this today, but <a target=_blank href='http:\/\/www.ansible.com\/windows' title='Ansible for Windows support'>Windows<\/a> is also supported) scenario as well, and we&#8217;ll be showing a bit of this today, to show you a bit about how Ansible works.<\/p>\n<p>Let&#8217;s, before that, do a glossary list of terms (mainly from Wikipedia .. thanks) we might use in relation to Ansible &#8230;<\/p>\n<ul>\n<li><a target=_blank title='Configuration management information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Configuration_management'>configuration management<\/a> &#8230; that&#8217;s Ansible<\/li>\n<li><a target=_blank title='Provisioning information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Provisioning#Server_provisioning'>provisioning<\/a> <a target=_blank title='Privisioning tool discussion' href='http:\/\/www.computerworld.com\/article\/2570007\/security0\/how-to-choose-a-provisioning-tool.html'>tool<\/a> &#8230; that&#8217;s Ansible<\/li>\n<li><a target=_blank title='Ansible OpenSource project' href='https:\/\/github.com\/ansible\/ansible'>Ansible<\/a> on GitHub by Michael DeHaan<\/li>\n<li><a target=_blank title='Secure shell information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Secure_Shell'>SSH<\/a><\/li>\n<li><a target=_blank title='YAML information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/YAML'>YAML<\/a> (and <a target=_blank href='https:\/\/www.google.com.au\/search?q=ansible+playbook&#038;ie=utf-8&#038;oe=utf-8&#038;gws_rd=cr&#038;ei=uFeIVuinAsO8mgX7uoqYBQ'>Playbooks<\/a>)<\/li>\n<li><a target=_blank title='JSON information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/JSON'>JSON<\/a><\/li>\n<li><a target=_blank title='Package manager information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Package_manager'>package manager<\/a> &#8230; eg. Homebrew, apt, YUM, MacPorts, pip, RPM, OpenPKG, nix, Conary, dpkg, Cygwin<\/li>\n<li><a target=_blank title='Jinja information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Jinja_(template_engine)'>Jinja<\/a> (Python) template engine<\/li>\n<li><a target=_blank title='Solution stack information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Solution_stack'>development stack<\/a><\/li>\n<li><a target=_blank title='Deployment information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Software_deployment'>deployment<\/a><\/li>\n<li><a target=_blank title='Virtual machine information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Virtual_machine'>virtual machine<\/a><\/li>\n<li><a target=_blank title='Automation information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Test_automation'>automation<\/a><\/li>\n<li><a target=_blank title='Source control information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Source_Code_Control_System'>source control<\/a><\/li>\n<li><a target=_blank title='Oracle VM VirtualNox' href='https:\/\/www.virtualbox.org\/'>VirtualBox<\/a><\/li>\n<li><a target=_blank title='Vagrant VMWare integration' href='https:\/\/www.vagrantup.com\/'>Vagrant<\/a> &#8230; more tomorrow <a target=_blank title='Vagrant Primer Tutorial will be available on 3rd January 2016' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/vagrant-primer-tutorial'>here<\/a><\/li>\n<li><a target=_blank title='GitHib repository' href='https:\/\/github.com\/'>GitHub<\/a><\/li>\n<li><a target=_blank title='PHPStorm IDE' href='https:\/\/www.jetbrains.com\/phpstorm\/'>PHPStorm<\/a> IDE we&#8217;ve mentioned before <a target=_blank title='PHPStorm postings here' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/phpstorm'>here<\/a> (integrates some of concepts above)<\/li>\n<\/ul>\n<p> &#8230; and direct you towards a good book, namely &#8220;Ansible Up and Running&#8221; by Lorin Hochstein, from which a lot of today&#8217;s blog posting&#8217;s information is derived &#8230; so, thanks.<\/p>\n<p>Okay, so what will we do with Ansible?<\/p>\n<p><b>Install<\/b> Ansible &#8230; on Mac OS X (via Terminal application) &#8230; and you&#8217;ll need <a target=_blank title='ssh via OpenSSH' href='http:\/\/www.openssh.com\/'>ssh<\/a> (if &#8220;ssh&#8221; on command line means nothing) &#8230; if you have <a target=_blank title='Homebrew Package Manager' href='http:\/\/brew.sh\/'>Homebrew<\/a> package manager installed you can go &#8230;<\/p>\n<p><code><a target=_blank title='Install Ansible on Mac OSX' href='https:\/\/valdhaus.co\/writings\/ansible-mac-osx\/'>$ brew install ansible<\/a><\/code><\/p>\n<p> &#8230; or you can install as root via Python&#8217;s pip package manager &#8230;<\/p>\n<p><code>$ sudo pip install ansible<\/code><\/p>\n<p> &#8230; or another way to install as root via the apt package manager &#8230;<\/p>\n<p><code>$ sudo apt-add-repository -y ppa:ansible\/ansible<br \/>\n$ sudo apt-get update<br \/>\n$ sudo apt-get install -y ansible<\/code><\/p>\n<p> &#8230; or you can install into a <a target=_blank title='Python landing page' href='https:\/\/www.python.org\/'>Python<\/a> (2.6 or above) <i>virtualenv<\/i> with <a target=_blank title='wget GNU' href='https:\/\/www.gnu.org\/software\/wget\/'>wget<\/a> via &#8230;<\/p>\n<p><code>$ wget https:\/\/raw.githubusercontent.com\/mitsuhiko\/pipsi\/master\/get-pipsi.py<br \/>\n$ python get-pipsi.py<br \/>\n$ pipsi install ansible<\/code><\/p>\n<p> ( with an updating of PATH to include <i>~\/.local\/bin<\/i> ) &#8230; or you can use GitHub via &#8230;<\/p>\n<p><code>$ git clone https:\/\/github.com\/ansible\/ansible.git --recursive<\/code><\/p>\n<p> &#8230; so that you can have &#8230;<\/p>\n<p><code>$ ansible<\/code><\/p>\n<p> &#8230; mean something at a command prompt (if not, a &#8220;find \/ -name &#8216;ansible&#8217; 2&gt; \/dev\/null&#8221; and adjustment of PATH in ~\/.profile may be necessary) &#8230; a suffix of &#8221; -vvvv&#8221; is useful for debugging purposes.<\/p>\n<p><b>Show you a 127.0.0.1 local web server with VirtualBox &#8220;Hello World&#8221; feeling example<\/b> using Ansible involved the need for installation, as required of Oracle&#8217;s <a target=_blank title='Virtaul VM VirtualBox by Oracle' href='https:\/\/www.virtualbox.org\/'>VirtualBox<\/a> and, for tomorrow specifically, we talk about <a target=_blank title='Vagrant VMWare integration' href='https:\/\/www.vagrantup.com\/'>Vagrant<\/a> via &#8230;<\/p>\n<p><!--img title='VirtualBox new Linux Ubuntu (64 bit)' src='http:\/\/www.rjmprogramming.com.au\/Mac\/Ansible\/ansible-51of.jpg'><\/img>\n<img title='VirtualBox new Linux Ubuntu (64 bit)' src='http:\/\/www.rjmprogramming.com.au\/Mac\/Ansible\/ansible-61of.jpg'><\/img--><\/p>\n<p><a target=_blank title='Vagrant Primer Tutorial will be available on 3rd January 2016' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/vagrant-primer-tutorial'><img title='Vagrant Primer Tutorial will be available on 3rd January 2016' src='http:\/\/www.rjmprogramming.com.au\/Mac\/vagrant_primer.jpg'><\/img><\/a><\/p>\n<p> &#8230; then, working off the install we made of Ansible we found an example <i>hosts<\/i> file off the install, and copied it to \/etc\/ansible\/hosts.orig as shown by &#8230;<\/p>\n<p><img title='Arrange hosts.orig Ansible file in \/etc\/ansible' src='http:\/\/www.rjmprogramming.com.au\/Mac\/Ansible\/ansible-71of.jpg'><\/img><\/p>\n<p><code><br \/>\n$ cd $HOME<br \/>\n$ mkdir mybox<br \/>\n$ cd mybox<br \/>\n$ mkdir playbooks<br \/>\n$ cd playbooks<br \/>\n$ vagrant init ubuntu\/trusty32<br \/>\n$ vagrant up<br \/>\n<\/code><\/p>\n<p><img title='Arrange hosts.orig Ansible file in \/etc\/ansible' src='http:\/\/www.rjmprogramming.com.au\/Mac\/Ansible\/ansible-92of.jpg'><\/img><br \/>\n<img title='Arrange hosts.orig Ansible file in \/etc\/ansible' src='http:\/\/www.rjmprogramming.com.au\/Mac\/Ansible\/ansible-93of.jpg'><\/img><br \/>\n<img title='Arrange hosts.orig Ansible file in \/etc\/ansible' src='http:\/\/www.rjmprogramming.com.au\/Mac\/Ansible\/ansible-94of.jpg'><\/img><\/p>\n<p><code><br \/>\n$ ssh -i .vagrant\/machines\/default\/virtualbox\/private_key vagrant@127.0.0.1 -p 2200<br \/>\n       vagrant@vagrant-ubuntu-trusty-32:~$ echo \"Hello World ... via Ansible\"<br \/>\n       Hello World ... via Ansible<br \/>\n       vagrant@vagrant-ubuntu-trusty-32:~$ exit<br \/>\n$ cat hosts<br \/>\n$ head -15 ansible.cfg<br \/>\n$ ansible testserver -m ping<br \/>\n$ ansible testserver -a uptime<br \/>\n<\/code><\/p>\n<p><img title='VirtualBox new Linux Ubuntu (32 bit)' src='http:\/\/www.rjmprogramming.com.au\/Mac\/Ansible\/ansible-97of.jpg'><\/img><br \/>\n<img title='VirtualBox new Linux Ubuntu (32 bit)' src='http:\/\/www.rjmprogramming.com.au\/Mac\/Ansible\/ansible-99of.jpg'><\/img><\/p>\n<p>Ansible is not alone with what it sets out to achieve &#8230; think Chef, Puppet or Salt &#8230; read more thanks to this <a target=_blank title='Useful link' href='https:\/\/serversforhackers.com\/an-ansible-tutorial'>useful link<\/a> for that information.<\/p>\n<p>We hope to be back with more about this powerful product as time goes by.  In the meantime, research into Ansible <a target=_blank href='https:\/\/www.google.com.au\/search?q=ansible+playbook&#038;ie=utf-8&#038;oe=utf-8&#038;gws_rd=cr&#038;ei=uFeIVuinAsO8mgX7uoqYBQ'>Playbooks<\/a> would be a great idea.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d19261' onclick='var dv=document.getElementById(\"d19261\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/server\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d19261' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d18803' onclick='var dv=document.getElementById(\"d18803\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/virtualdisk\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d18803' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In understanding what is out there on the net, tend to want to form relationships in my mind, between applications. So here&#8217;s a good one &#8230; VirtualBox with Vagrant &#8230; or perhaps &#8230; VirtualMachine with Vagrant. So here&#8217;s another one &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/vagrant-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,37],"tags":[1756,585,1663,932,1755,1757,1754,1377,1378],"class_list":["post-18803","post","type-post","status-publish","format-standard","hentry","category-elearning","category-tutorials","tag-environment","tag-ide","tag-model","tag-php","tag-phpstorm","tag-system","tag-vagrant","tag-virtual-machine","tag-virtualbox"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/18803"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=18803"}],"version-history":[{"count":12,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/18803\/revisions"}],"predecessor-version":[{"id":19370,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/18803\/revisions\/19370"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=18803"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=18803"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=18803"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}