{"id":3524,"date":"2015-09-30T18:01:14","date_gmt":"2015-10-01T00:01:14","guid":{"rendered":"http:\/\/benincosa.com\/?p=3524"},"modified":"2015-09-30T18:02:07","modified_gmt":"2015-10-01T00:02:07","slug":"using-packer-with-cisco-metapod","status":"publish","type":"post","link":"https:\/\/benincosa.com\/?p=3524","title":{"rendered":"Using Packer with Cisco Metapod"},"content":{"rendered":"<p>Packer is such a cool tool for creating images that are used with any cloud provider. \u00a0With the same packer recipe you can create common images on AWS, Digital Ocean, OpenStack, and more! \u00a0The <a href=\"https:\/\/www.packer.io\/docs\/builders\/openstack.html\">Packer documentation<\/a> already comes with an example of running with Metapod (formerly Metacloud).<\/p>\n<p>I wanted to show an example of how I use Packer to create images for both AWS and OpenStack. \u00a0Without any further commentary, here is what it looks like:<\/p>\n<pre class=\"lang:js decode:true \">{\r\n \"builders\" : [{\r\n \"type\": \"openstack\",\r\n \"ssh_username\": \"core\", \r\n \"image_name\": \"coreos-jenkinslave\",\r\n \"source_image\": \"4d723f4e-1cd0-4521-ae77-117a9cd18d24\",\r\n \"use_floating_ip\": \"true\",\r\n \"floating_ip\": \"some public IP\",\r\n \"flavor\": \"5\" \r\n }, \r\n {\r\n \"type\": \"amazon-ebs\",\r\n \"region\": \"us-west-2\",\r\n \"ssh_username\": \"core\", \r\n \"ami_name\": \"coreos-jenkinsslave {{ timestamp }}\",\r\n \"source_ami\": \"ami-ef8b90df\", \r\n \"instance_type\": \"t1.micro\"\r\n }\r\n],\r\n \"provisioners\": [{\r\n \"type\": \"shell\",\r\n \"inline\": [\r\n \"sleep 30\",\r\n \"mkdir \/home\/core\/java\",\r\n \"cd \/home\/core\/java\",\r\n \"wget -O java.tar.gz http:\/\/javadl.sun.com\/webapps\/download\/AutoDL?BundleId=83376\",\r\n \"tar xzvf java.tar.gz\",\r\n \"rm java.tar.gz\",\r\n \"rm \/home\/core\/.bashrc\",\r\n \"echo 'export PATH=$PATH:\/home\/core\/java\/jre1.7.0_51\/bin\/' &gt; \/home\/core\/.bashrc\"\r\n ] \r\n }] \r\n}<\/pre>\n<p>There are two sections to this file. \u00a0The builders: \u00a0AWS and OpenStack, and the provisioners (the code that gets executed on both of them.) \u00a0We specify as many different platforms as we have and then tell it what to do. \u00a0When we are finished executing this script, our Jenkins slaves will be ready on all of our platforms. \u00a0This is super nice because now we just point our robots to which ever system we want and we have automated control!<\/p>\n<p>With Metapod there were a few hooks:<\/p>\n<ul>\n<li>By default images are not created with public IP addresses, so you need to grab one for it to work correctly.<\/li>\n<li>Packer actually creates a running image but then logs into it via SSH to configure it. \u00a0So this is required if you are running this from outside the firewall!<\/li>\n<\/ul>\n<p>Hybrid Cloud isn&#8217;t about moving workloads between two clouds, its about having tools that can operate and deploy and tear down workloads to any cloud. \u00a0Packer is a great foundation tool because it creates the same image in both places.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Packer is such a cool tool for creating images that are used with any cloud provider. \u00a0With the same packer recipe you can create common images on AWS, Digital Ocean, OpenStack, and more! \u00a0The Packer documentation already comes with an example of running with Metapod (formerly Metacloud). I wanted to show an example of how&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/posts\/3524"}],"collection":[{"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/benincosa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3524"}],"version-history":[{"count":2,"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/posts\/3524\/revisions"}],"predecessor-version":[{"id":3527,"href":"https:\/\/benincosa.com\/index.php?rest_route=\/wp\/v2\/posts\/3524\/revisions\/3527"}],"wp:attachment":[{"href":"https:\/\/benincosa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3524"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/benincosa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3524"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/benincosa.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3524"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}