Skip to content

Instantly share code, notes, and snippets.

@tbatchelli
Created November 9, 2010 02:37
Show Gist options
  • Save tbatchelli/668618 to your computer and use it in GitHub Desktop.
Save tbatchelli/668618 to your computer and use it in GitHub Desktop.
(ns bacug
(:use org.jclouds.compute
org.jclouds.aws.ebs
clojure.pprint))
;; define a connection to the cloud provider
(def compute (compute-service "ec2"
"<identity>"
"<credentials>" :ssh))
;; let's see what locations this provider has
(pprint (locations compute))
;; create a node, with a hard drive of 250GB
(with-compute-service [compute]
(def node (run-node "some_name"))
(create-volume :node node :size 250 :device "/dev/sdj"))
;; alternative way
(comment
(run-nodes "some_name" 2 compute))
;; alternative way with a template.
(comment
(run-nodes "some_name" 2 compute
(build-template
service
{:os-family :ubuntu
:smallest true
:image-name-matches "10.04"))))
;; ok. let's see the node that we just created
(pprint (nodes compute))
;; let's see what nodes are actually running
(map running? (nodes compute))
;; ** try sshing to any of the nodes
;; remove the nodes
(destroy-nodes-with-tag "some_name" compute)
;; confirm the nodes are destroyed
(map running? (nodes compute))
;;;;;;;;;;;;
;; pallet ;;
;;;;;;;;;;;;
(ns bacug-haproxy
(:use pallet.maven
[pallet.compute :as compute])
(:require webapp-nodes.nodes))
;; define the compute service, this time form maven settings
(def service (compute-service-from-settings))
;; create one node in the 'proxied' tag
(pallet.core/converge
{webapp-nodes.nodes/proxied 1}
:compute service :phase [:deploy-nano-webapp :restart-tomcat])
;; SSH in!
;; deploy a webapp on the nodes in the 'proxied' tag
(pallet.core/lift webapp-nodes.nodes/proxied :compute service :phase :deploy-nano-webapp)
;; make the deploy faster --> use a blobstore!
(def blobstore (pallet.blobstore/blobstore-from-settings))
;;;;; remember to update the proxied crate
;; deploy 3 proxied nodes with webapp + 1 haproxy,
(pallet.core/converge
{webapp-nodes.nodes/proxied 2
webapp-nodes.nodes/haproxy 1}
:compute service
:blobstore blobstore
:phase [:deploy-from-blobstore :restart-haproxy :restart-tomcat])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment