Skip to content

Fixes needed to get nginx to build #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion resources/crate/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
25 changes: 16 additions & 9 deletions src/pallet/crate/nginx.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@
(: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"})
{"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")
Expand All @@ -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
Expand Down Expand Up @@ -95,7 +96,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]
Expand Down Expand Up @@ -194,7 +195,6 @@
(format "%s/mime.types.default" nginx-conf-dir)
:action :delete)))


(defn init
"Creates a nginx init script."
[session & {:as options}]
Expand All @@ -206,7 +206,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:
Expand All @@ -215,8 +222,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
Expand Down
4 changes: 2 additions & 2 deletions test/pallet/crate/nginx_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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}}}
Expand Down