Skip to content

Instantly share code, notes, and snippets.

@vizanto
Created September 16, 2011 12:32
Show Gist options
  • Save vizanto/1222023 to your computer and use it in GitHub Desktop.
Save vizanto/1222023 to your computer and use it in GitHub Desktop.
Tomcat on vmfest managed Ubuntu VM _almost_ configured.
(ns nodes.core
(:require [pallet compute, resource]
pallet.compute.vmfest
vmfest.manager, vmfest.virtualbox.image
[pallet.crate.tomcat :as tomcat]
[pallet.action.package :as package]
[pallet.action.exec-script :as exec-script]
[pallet.utils :as utils]
[pallet.session :as session]
[pallet.script.lib])
(:use pallet.core
pallet.thread-expr
pallet.action.package
clojure.contrib.with-ns))
;
; Override basic config to add SATA controller
;
(with-ns 'pallet.compute.vmfest
(defn basic-config [m {:keys [memory-size cpu-count] :as parameters}]
(let [parameters (merge {:memory-size 512 :cpu-count 1} parameters)]
(manager/configure-machine m parameters)
(manager/set-bridged-network m "en0: Ethernet")
(add-sata-controller m))))
(def ubuntu64 {:os-family :ubuntu, :os-64-bit true})
(def vmservice (pallet.compute/compute-service-from-config-file :virtualbox))
(def testservice (pallet.compute/compute-service-from-config-file :testvm))
(def generic-node
(node-spec
:image ubuntu64
:hardware {:min-cores 2, :min-ram 1024}))
(def tomcat-settings
(tomcat/settings-map
{:server (tomcat/server
:port 8005 :shutdown "SHUTDOWN"
(tomcat/global-resources)
(tomcat/service
(tomcat/engine "Catalina" "localhost"
;(tomcat/valve :request-dumper)
(tomcat/host "localhost" "websa" :unpackWARs true))
;
; (host ...) explodes when lifting:
;
;
(tomcat/connector :port 8009 :protocol "AJP/1.3" :redirectPort 8443)
(tomcat/connector :port 8081 :protocol "HTTP/1.1" :redirectPort 8443 :connectionTimeout 20000 :URIEncoding "UTF-8")
))}))
(def webserver-conf
(server-spec
:phases {:configure (pallet.phase/phase-fn
(pallet.crate.java/java)
(tomcat/install)
(tomcat/server-configuration)
(tomcat/deploy "probe"
:url "http://psi-probe.googlecode.com/files/probe-2.2.3.zip"
:md5 "32e25f8c4e5f87da884482d6d2303fd7"
:sha1 "ca600308c5780f4a0f3b54a96e25ced785069ddf")
(tomcat/init-service :action :restart)
)
:settings (pallet.phase/phase-fn
(pallet.crate.tomcat/settings tomcat-settings))
}))
(def tserver (group-spec "tester"
:node-spec (node-spec :image {:os-family :ubuntu})
:extends [webserver-conf]))
(defn tserver-exec [config-fn] (merge tserver {:phases {:configure config-fn}}))
(defn lift-test-nodes []
(lift tserver :phase :configure :compute testservice))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment