Skip to content

Instantly share code, notes, and snippets.

@xeqi
Last active December 14, 2015 23:39
Show Gist options
  • Save xeqi/5167271 to your computer and use it in GitHub Desktop.
Save xeqi/5167271 to your computer and use it in GitHub Desktop.
immutant and pallet
(require
'[pallet.crate.git :refer [git clone]]
'[pallet.crate.java :refer [java]]
'[pallet.crate.lein :refer [lein leiningen]])
(def repo "git://github.com/jcrossley3/random-apps-of-kindness.git")
(def demo-directory "random-apps-of-kindness/demo")
(defplan setup-machine
[]
(packages
:apt ["unzip"]
:aptitude ["unzip"]))
(defplan clone-repo
[]
(with-action-options {:script-prefix :no-sudo}
(remote-directory ".ssh" :mode "0755")
(remote-file
".ssh/config"
:content "Host github.com\n\tStrictHostKeyChecking no\n"
:no-versioning true) ; pallet beta.1 workaround
(clone repo)))
(defplan immutant-deploy
[]
(with-action-options {:script-prefix :no-sudo :script-dir demo-directory}
(lein "with-profiles" "+openshift" "immutant" "deploy")))
(defplan immutant-plugin
[]
(with-action-options {:script-prefix :no-sudo}
(lein "self-install")
(remote-file ".lein/profiles.clj"
:content
(pr-str {:user {:plugins '[[lein-immutant "0.17.1"]]}}))))
(defplan immutant-install
[]
(with-action-options {:script-prefix :no-sudo}
(lein "immutant" "install")))
(defplan immutant-run
[]
(with-action-options {:script-prefix :no-sudo}
(exec-checked-script
"Run immutant"
("(" nohup ("lein" immutant run) "&" ")")
("sleep" 5))))
(defproject immutant-pallet-example
:provider {:vmfest
{:node-spec
{:image {:os-family :ubuntu :os-version-matches "12.04"
:os-64-bit true}}
:group-suffix "u1204"
:selectors #{:default}}}
:groups [(group-spec "immutant-pallet-example"
:extends [with-automated-admin-user
(java {}) (leiningen {}) (git {})]
:phases {:configure (plan-fn
(setup-machine)
(clone-repo)
(immutant-plugin)
(immutant-install)
(immutant-deploy)
(immutant-run))})])
{:user {:plugins [[com.palletops/pallet-lein "0.6.0-beta.6"]]}
:pallet {:dependencies
[[org.cloudhoist/pallet-vmfest "0.3.0-alpha.1"]
[org.clojars.tbatchelli/vboxjxpcom "4.2.4"]
[com.palletops/pallet "0.8.0-beta.4"]
[com.palletops/java-crate "0.8.0-beta.1"]
[com.palletops/lein-crate "0.8.0-alpha.1"]
[com.palletops/git-crate "0.8.0-alpha.1"]
[ch.qos.logback/logback-classic "1.0.9"]
[org.slf4j/jcl-over-slf4j "1.7.2"]]
:jvm-opts ^:replace ["-XX:+TieredCompilation"]}}
(defproject immutant-pallet-example "0.0.1-SNAPSHOT")
I think you can add a base vm image with `lein pallet add-vmfest-image https://s3.amazonaws.com/vmfest-images/ubuntu-12.04.vdi.gz` though I had some problems with the meta file. Always could ask in #pallet if theres a problem.
-----
xeqi@thinky:~/workspace/vms/pallet-example$ lein pallet up
21:53:00.518 [clojure-agent-send-off-pool-0] WARN vmfest.manager - ensure-image-is-registered: /home/xeqi/.vmfest/models/vmfest-ubuntu-12.04.vdi is not mutable.
=====================================================================================================
:primary-ip | :private-ip | :hostname | :group-name | :roles
=====================================================================================================
192.168.56.101 | | immutant-pallet-exampleu1204-0 | immutant-pallet-exampleu1204 |
=====================================================================================================
xeqi@thinky:~/workspace/vms/pallet-example$ ssh -L 8080:localhost:8080 -L 7888:localhost:7888 192.168.56.101
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic x86_64)
* Documentation: https://help.ubuntu.com/
System information disabled due to load higher than 1.0
Last login: Thu Mar 14 22:57:25 2013 from 192.168.56.1
xeqi@ubuntu1204:~$ ls
nohup.out random-apps-of-kindness
xeqi@ubuntu1204:~$ ls random-apps-of-kindness/demo
doc project.clj README.md resources src target test
xeqi@ubuntu1204:~$ cat nohup.out
Starting Immutant: /home/xeqi/.lein/immutant/current/jboss/bin/standalone.sh
=========================================================================
....
@arnaudbos
Copy link

This would be perfect for being released as an immutant-crate! Have your considered it?
It seems to me that just returning a server-spec in an immutant or server-spec function would do the trick.

I mean, the immutant install steps at least, the others are deployment specific.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment