Skip to content

Instantly share code, notes, and snippets.

(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"
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
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")
(: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)
Doesn't work:
=============
...yadda yadda...
:dependencies [[org.clojure/clojure "1.2.0"]
[org.clojure/clojure-contrib "1.2.0"]
[org.jclouds.provider/aws-s3 "1.0-SNAPSHOT"]]
:dev-dependencies [[org.jclouds/jclouds-all "1.0-SNAPSHOT"]
[swank-clojure "1.3.1"]
[cake-pallet "0.5.0"]
[org.cloudhoist/pallet "0.5.1-SNAPSHOT"]
@davidsantiago
davidsantiago / Fixed Tomcat crate to have a settings phase, still happens on 3rd deploy.
Created June 4, 2011 19:45
Tomcat logs from creating a fresh VM and installing/deploying the same WAR 3 times.
david@ubuntu:~$ sudo cat /var/log/tomcat6/catalina.2011-06-04.log
Jun 4, 2011 7:09:57 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Jun 4, 2011 7:09:57 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 2689 ms
Jun 4, 2011 7:09:57 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Jun 4, 2011 7:09:57 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.28
Jun 4, 2011 7:09:57 PM org.apache.catalina.startup.HostConfig deployDirectory
David-Santiagos-Computer:servlet David$ cake pallet lift com.battletheory.deploy.nodes/main :deploy @dev -- -P virtualbox
Exception in thread "main" java.lang.Exception: Unable to resolve symbol: execute in this context (file.clj:40)
at clojure.lang.Compiler.analyze(Compiler.java:5205)
at clojure.lang.Compiler.analyze(Compiler.java:5151)
at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3036)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:5371)
at clojure.lang.Compiler.analyze(Compiler.java:5190)
at clojure.lang.Compiler.analyze(Compiler.java:5151)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:4670)
at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:4941)
(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))
INFO core - retrieving nodes
INFO core - converging nodes
INFO core - adjust-node-count :stage 1
INFO core - Starting 1 nodes for :stage os-family
INFO jclouds - OS is :ubuntu
INFO jclouds - building node template for :stage
INFO jclouds - authorizing /Users/David/.ssh/id_rsa.pub
INFO jclouds - options {:inbound-ports [22 80 443], :image-id "us-east-1/ami-a6f504cf", :hardware-id "m1.small"}
WARN compute - to avoid creating temporary keys in aws-ec2, use templateOption overrideLoginCredentialWith(id_rsa)
WARN compute - to avoid creating temporary keys in aws-ec2, use templateOption overrideLoginCredentialWith(id_rsa)
echo "Add java environment to /etc/environment..."
{ pallet_set_env() {
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}"
k=$1
v=$2
s=$3
if [ ! $(grep "${s}" /etc/environment) ]; then
sed -i -e "/${k}/ d" -e "$ a \\
${s}" /etc/environment