Skip to content

Instantly share code, notes, and snippets.

(:emacs-rex
(swank:compile-string-for-emacs "(defn parse-template-from-string\n [template-string]\n (let [template-lines (str/split-lines template-string)]\n ))\n" "core.clj" 100 "/Users/David/Documents/Development/Clojure/pochoir/src/pochoir/core.clj" 'nil)
"pochoir.core" t 42)
(:return
(:abort "java.lang.Exception: No such namespace: pochoir.core (/Users/David/Documents/Development/Clojure/pochoir/src/pochoir/core.clj:4)")
42)
So, I have this file PROJECT_ROOT/dev-resources/config/nginx/battletheory.conf, and it is a template intended for use with pallet.template. In the past (when it wasn't a template), I have successfully done
(remote-file/remote-file "/etc/nginx/sites-enabled/battletheory.conf"
:local-file "dev-resources/config/nginx/battletheory.conf")
Now I need battletheory.conf to be a template, so I am trying
(remote-file/remote-file "/etc/nginx/sites-enabled/battletheory.conf"
:local-file "dev-resources/config/nginx/battletheory.conf")
David-Santiagos-Computer:servlet David$ cake repl @production
user=> (pallet.environment/environment (pallet.compute/compute-service-from-config-file :aws))
{:groups {:main {:image {:os-family :ubuntu, :os-description-matches "10.10", :hardware-id "m1.small", :image-id "us-east-1/ami-1a837773", :inbound-ports [22 80 443]}}, :stage {:image {:hardware-id "m1.small", :image-id "us-east-1/ami-a6f504cf", :inbound-ports [22 80 443]}}}}
David-Santiagos-Computer:servlet David$ cake pallet converge com.battletheory.deploy.nodes/stage 1 @production -- -P aws
;; Meanwhile, in the log...
INFO core - retrieving nodes
INFO core - converging nodes
INFO core - adjust-node-count :stage 1
(defcontext production
:mode "production"
;; Pallet environment
:environment {:groups {:main {:image {:os-family :ubuntu
:os-description-matches "10.10"
:hardware-id "m1.small"
:image-id "us-east-1/ami-a6f504cf"
:inbound-ports [22 80 443]}}
:stage {:image {:os-family :ubuntu
:os-description-matches "10.10"
{:phases {:configure #<nodes$fn__12253 com.battletheory.deploy.nodes$fn__12253@197e2a6>,
:deploy #<nodes$fn__12258 com.battletheory.deploy.nodes$fn__12258@a123fb>,
:bootstrap #<nodes$fn__12251 com.battletheory.deploy.nodes$fn__12251@1417095>,
:setup-db #<nodes$fn__12256 com.battletheory.deploy.nodes$fn__12256@1466dd3>},
:group-name :server,
:image {:os-family :ubuntu, :os-version "10.10"}}
@davidsantiago
davidsantiago / gist:926154
Created April 18, 2011 20:55
SSH Port forwarding in Pallet!
(defmacro with-ssh-tunnel->
"Execute the body with an ssh-tunnel available for the ports given in the
tunnels map. tunnels should be a map from local ports (integers) to either
1) An integer remote port. Remote host is assumed to be 'localhost'.
2) A vector of remote host and remote port. eg, [\"yahoo.com\" 80].
Automatically closes the connection (and port forwards) on completion."
[request tunnels & body]
`(clj-ssh/with-ssh-agent [(execute/default-agent)]
(let [user# (:user ~request)
node-address# (compute/node-address (:target-node ~request))
ERROR in (large-container-list-test) (:-1)
expected: (= total-blobs (count-blobs *blobstore* container-name))
actual: java.lang.reflect.UndeclaredThrowableException: null
at org.jclouds.blobstore.config.$Proxy30.countBlobs (:-1)
org.jclouds.blobstore2$count_blobs.invoke (blobstore2.clj:256)
org.jclouds.blobstore2_test/fn (blobstore2_test.clj:91)
clojure.test$test_var$fn__6131.invoke (test.clj:688)
clojure.test$test_var.invoke (test.clj:688)
clojure.test$test_all_vars$fn__6135$fn__6142.invoke (test.clj:704)
org.jclouds.blobstore2_test$clean_stub_fixture$fn__705.invoke (blobstore2_test.clj:34)
;; Instead of sign-blob-request
(defn sign-get
"Get a signed http GET request for manipulating a blob in another
application, Ex. curl."
[container-name name ^Blobstore blobstore]
(.signGetBlob (.. blobstore getContext getSigner) container-name name))
(defn sign-put
"Get a signed http PUT request for manipulating a blob in another
application, Ex. curl. A Blob with at least the name and content-length
context.getBlobStore().blobBuilder(key).userMetadata(ImmutableMap.of("Adrian", "powderpuff")).payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN).calculateMD5().build()
;; 1
(build-blob blobstore :metadata {"Adrian" "powderpuff"} :payload TEST_STRING :content-type MediaType/TEXT_PLAIN :md5 true)
;; 2
(build-blob blobstore :metadata {"Adrian" "powderpuff"}
:payload (blob-payload TEST_STRING :content-type MediaType/TEXT_PLAIN :md5 true))
(def server-system (core/node-spec :image {:os-family :ubuntu
:os-version "10.10"}))
(def server-config
(core/server-spec
:phases {:bootstrap (phase/phase-fn (crates/bootstrap))
:configure (phase/phase-fn
(crates/java)
(crates/iptables)
(crates/couchdb)