Skip to content

Instantly share code, notes, and snippets.

@cloudartisan
Created June 17, 2011 04:11
Show Gist options
  • Save cloudartisan/1030854 to your computer and use it in GitHub Desktop.
Save cloudartisan/1030854 to your computer and use it in GitHub Desktop.
Pallet source for deployment to staging
(ns staging.core
(:require
[pallet.core :as core]
[pallet.compute :as compute]
[pallet.resource :as resource]
[pallet.stevedore :as stevedore]
[pallet.crate.automated-admin-user :as automated-admin-user]
[staging.crate.mongodb :as mongodb]))
(def ec2-service
(compute/compute-service-from-config-file :ec2))
(core/defnode mongodb
"MongoDB Node"
{:os-family :ubuntu
:os-description-matches "11.04"
:os-64-bit true
:min-ram 8192
:min-cores 2
:image-id "us-east-1/ami-1aad5273"
:hardware-id "m1.large"
:inbound-ports [22]}
:bootstrap (resource/phase (automated-admin-user/automated-admin-user))
:configure (resource/phase (mongodb/mongodb-10gen)))
(ns staging.crate.mongodb
(:require
[pallet.action.exec-script :as exec-script]
[pallet.action.directory :as directory]
[pallet.action.file :as file]
[pallet.action.package :as package]
[pallet.script :as script]))
(def mongodb-db-path "/mnt/mongodb/db")
(def mongodb-log "/var/log/mongodb.log")
(script/defscript mongod [])
(script/defimpl mongod :default []
(sudo mongod --fork --dbpath ~mongodb-db-path --logpath ~mongodb-log --logappend))
(defn mongodb-10gen
"Install MongoDB server (from the 10gen repository)"
[request]
(-> request
(package/package-source
"10gen"
:aptitude {:source-type "deb"
:url "http://downloads-distro.mongodb.org/repo/ubuntu-upstart"
:scopes ["dist" "10gen"]
:key-id "7F0CEB10"} )
(package/package-manager :update)
(package/package "mongodb-10gen" :action :install)
(exec-script/exec-checked-script
"Start MongoDB server"
(mongod))))
(defproject staging "0.0.1"
:description "Assistly Staging"
:dependencies [[org.clojure/clojure "1.2.1"]
[org.clojure/clojure-contrib "1.2.0"]
[org.cloudhoist/pallet "0.6.1"]
[org.cloudhoist/pallet-crates-all "0.5.0"]
[org.jclouds.provider/aws-ec2 "1.0.0"]
[org.jclouds.provider/aws-s3 "1.0.0"]
[org.jclouds.driver/jclouds-jsch "1.0.0"]
[org.jclouds.driver/jclouds-log4j "1.0.0"]
[log4j/log4j "1.2.14"]]
:dev-dependencies [[org.cloudhoist/pallet-lein "0.4.0"]]
:repositories {"sonatype-snapshot" "https://oss.sonatype.org/content/repositories/snapshots/"
"sonatype" "https://oss.sonatype.org/content/repositories/releases"})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment