{"id":19261,"date":"2016-01-02T03:01:27","date_gmt":"2016-01-01T17:01:27","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=19261"},"modified":"2016-05-14T21:37:57","modified_gmt":"2016-05-14T11:37:57","slug":"ansible-hello-world-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/ansible-hello-world-primer-tutorial\/","title":{"rendered":"Ansible Hello World Primer Tutorial"},"content":{"rendered":"<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 id=vibit><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","protected":false},"excerpt":{"rendered":"<p>The role of a programmer is expanding into deployment with software tools such as Ansible, because it has the capability of making the piloting of automation systems &#8220;approachable&#8221; as an &#8220;art&#8221;. Why would you want to &#8220;pilot an automation system&#8221;? &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/ansible-hello-world-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,18,19,25,29,31,33,37],"tags":[1880,249,1768,558,611,707,886,1769,1122,1166,1176,1319,1339,1754],"class_list":["post-19261","post","type-post","status-publish","format-standard","hentry","category-elearning","category-hardware","category-installers","category-networking","category-operating-system","category-projects","category-software","category-tutorials","tag-ansible","tag-configuration","tag-deployment","tag-hello-world","tag-install","tag-linux","tag-operations","tag-provisioning","tag-server","tag-software-2","tag-source-control","tag-tutorial","tag-unix","tag-vagrant"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/19261"}],"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=19261"}],"version-history":[{"count":15,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/19261\/revisions"}],"predecessor-version":[{"id":21985,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/19261\/revisions\/21985"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=19261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=19261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=19261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}