From 44bba81f2c2df50f2bf9b62a82140e49081bfeeb Mon Sep 17 00:00:00 2001 From: Blake Smith Date: Mon, 9 Apr 2012 00:13:24 -0500 Subject: [PATCH 1/5] Make sites-* files end in .conf to avoid conflicts with .md5 and other files --- resources/crate/nginx/nginx.conf | 2 +- src/pallet/crate/nginx.clj | 4 ++-- test/pallet/crate/nginx_test.clj | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/crate/nginx/nginx.conf b/resources/crate/nginx/nginx.conf index b965c3b..4ae793d 100644 --- a/resources/crate/nginx/nginx.conf +++ b/resources/crate/nginx/nginx.conf @@ -29,5 +29,5 @@ http { gzip_types ~(apply str (interpose " " gzip_types)); include /etc/nginx/conf.d/*.conf; - include /etc/nginx/sites-enabled/*; + include /etc/nginx/sites-enabled/*.conf; } diff --git a/src/pallet/crate/nginx.clj b/src/pallet/crate/nginx.clj index 0ffb6e0..6fcfc04 100644 --- a/src/pallet/crate/nginx.clj +++ b/src/pallet/crate/nginx.clj @@ -215,8 +215,8 @@ :locations -- locations (a seq of maps, with keys :location, :root :index, :proxy_pass :passenger-enabled :rails-env)" [session name & {:keys [locations action] :or {action :enable} :as options}] - (let [available (format "%s/sites-available/%s" nginx-conf-dir name) - enabled (format "%s/sites-enabled/%s" nginx-conf-dir name) + (let [available (format "%s/sites-available/%s.conf" nginx-conf-dir name) + enabled (format "%s/sites-enabled/%s.conf" nginx-conf-dir name) site (fn [session filename] (let [locations (string/join \newline diff --git a/test/pallet/crate/nginx_test.clj b/test/pallet/crate/nginx_test.clj index 7ef1584..6eb47e2 100644 --- a/test/pallet/crate/nginx_test.clj +++ b/test/pallet/crate/nginx_test.clj @@ -16,10 +16,10 @@ (directory/directory "/etc/nginx/sites-available") (directory/directory "/etc/nginx/sites-enabled") (remote-file/remote-file - "/etc/nginx/sites-enabled/mysite" + "/etc/nginx/sites-enabled/mysite.conf" :content "server {\n listen 80;\n server_name localhost;\n\n access_log /var/log/nginx/access.log;\n\nlocation / {\n root /some/path;\n index index.html index.htm;\n \n \n \n}\n\nlocation /a {\n \n index index.html index.htm;\n proxy_pass localhost:8080;\n \n \n}\n\n}\n") (file/file - "/etc/nginx/sites-available/mysite" :action :delete :force true))) + "/etc/nginx/sites-available/mysite.conf" :action :delete :force true))) (first (build-actions/build-actions {:server {:group-name :n :image {:os-family :ubuntu}}} From c6b38f56667c7cf8d29d9791142b6b30827b5360 Mon Sep 17 00:00:00 2001 From: Blake Smith Date: Mon, 9 Apr 2012 00:14:09 -0500 Subject: [PATCH 2/5] Include build-essential for gcc/make --- src/pallet/crate/nginx.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pallet/crate/nginx.clj b/src/pallet/crate/nginx.clj index 6fcfc04..d96170c 100644 --- a/src/pallet/crate/nginx.clj +++ b/src/pallet/crate/nginx.clj @@ -20,7 +20,7 @@ (:use pallet.thread-expr)) (def src-packages - ["libpcre3" "libpcre3-dev" "libssl" "libssl-dev"]) + ["libpcre3" "libpcre3-dev" "libssl" "libssl-dev" "build-essential"]) (def nginx-md5s {"0.7.65" "abc4f76af450eedeb063158bd963feaa"}) From f12bf8c670e108bb4943f0b2b4da5bffd00f97e4 Mon Sep 17 00:00:00 2001 From: Blake Smith Date: Mon, 9 Apr 2012 00:14:47 -0500 Subject: [PATCH 3/5] Hardcode /tmp directory to download the tarball --- src/pallet/crate/nginx.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pallet/crate/nginx.clj b/src/pallet/crate/nginx.clj index d96170c..f9d7d3c 100644 --- a/src/pallet/crate/nginx.clj +++ b/src/pallet/crate/nginx.clj @@ -95,7 +95,7 @@ modules (options :version) basename (str "nginx-" version) tarfile (str basename ".tar.gz") - tarpath (str (stevedore/script (tmp-dir)) "/" tarfile) + tarpath (str "/tmp/" tarfile) options (if (:passenger options) (update-in options [:add-modules] From 116f87ffeb880dfb5bbe400cce299c124c4c3535 Mon Sep 17 00:00:00 2001 From: Blake Smith Date: Mon, 9 Apr 2012 01:11:45 -0500 Subject: [PATCH 4/5] Add a method to control the nginx service --- src/pallet/crate/nginx.clj | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pallet/crate/nginx.clj b/src/pallet/crate/nginx.clj index f9d7d3c..4c16086 100644 --- a/src/pallet/crate/nginx.clj +++ b/src/pallet/crate/nginx.clj @@ -194,7 +194,6 @@ (format "%s/mime.types.default" nginx-conf-dir) :action :delete))) - (defn init "Creates a nginx init script." [session & {:as options}] @@ -206,7 +205,14 @@ (template/find-template nginx-init-script session)) :literal true) (if-not-> (:no-enable options) - (service/service "nginx" :action :enable)))) + (service/service "nginx" :action :enable)))) + +(defn control + "Control (start, stop, restart) the nginx service" + [session action] + (-> + session + (service/service "nginx" :action action))) (defn site "Enable or disable a site. Options: From 833f14fa82375fc7d8908426a8f5c1d1927facff Mon Sep 17 00:00:00 2001 From: Blake Smith Date: Mon, 9 Apr 2012 01:26:20 -0500 Subject: [PATCH 5/5] Update download URL and add support for 1.1.18 (and make it the default) --- src/pallet/crate/nginx.clj | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pallet/crate/nginx.clj b/src/pallet/crate/nginx.clj index 4c16086..96d3794 100644 --- a/src/pallet/crate/nginx.clj +++ b/src/pallet/crate/nginx.clj @@ -23,10 +23,11 @@ ["libpcre3" "libpcre3-dev" "libssl" "libssl-dev" "build-essential"]) (def nginx-md5s - {"0.7.65" "abc4f76af450eedeb063158bd963feaa"}) + {"0.7.65" "abc4f76af450eedeb063158bd963feaa" + "1.1.18" "82f4b4b1fba68f5f83cc2c641fb6c4c5"}) (defn ftp-path [version] - (format "http://sysoev.ru/nginx/nginx-%s.tar.gz" version)) + (format "http://nginx.org/download/nginx-%s.tar.gz" version)) (def nginx-conf-dir "/etc/nginx") (def nginx-install-dir "/opt/nginx") @@ -45,7 +46,7 @@ (def nginx-mime-conf "crate/nginx/mime.types") (def nginx-defaults - {:version "0.7.65" + {:version "1.1.18" :modules [:http_ssl_module :http_gzip_static_module]}) (def nginx-default-conf