itamae-plugin-recipe-nginx_build 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b75d4b79a1bb893aeb03a62e0731e4aada34b603
4
+ data.tar.gz: 7268167d0dc35809ab82a9ef5fa5a395db03e3b5
5
+ SHA512:
6
+ metadata.gz: a551bfb637e8233afaa7c9a2e078b3fceaefef34c67b5c3c94448e494cd20ff7adc9ae02d4fa1f5fd6c6c2ba45c59923d183a7a7acf4e4b2b63eb369132b6767
7
+ data.tar.gz: c5cac409991322c39061199f88ff6f2947f94da269b8e21127d526c070102b37741244b3d73a7f1d79eb51327b0ca720c5c141cabe1682792e4ec03db26a344f
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .idea/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in itamae-plugin-recipe-nginx_build.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # Itamae::Plugin::Recipe::NginxBuild
2
+
3
+ Itamae recipe plugin for nginx-build
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'itamae-plugin-recipe-nginx_build'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install itamae-plugin-recipe-nginx_build
20
+
21
+ ## Usage
22
+
23
+ ### Install
24
+
25
+ ```ruby
26
+ include_recipe "nginx_build"
27
+ include_recipe "nginx_build::install"
28
+ ```
29
+
30
+ ### Option
31
+
32
+ all parameter is optional.
33
+
34
+ ```yaml
35
+ nginx_build:
36
+ platform: linux ( or darwin )
37
+ version: 0.6.4
38
+ bin: /usr/local/bin/
39
+ nginx_version: 1.8.0
40
+ nginx_user: nginx
41
+ nginx_group: nginx
42
+ nginx_sbin: /usr/sbin/nginx
43
+ nginx_conf: /etc/nginx/nginx.conf
44
+ nginx_pid: /var/run/nginx.pid
45
+ modules:
46
+ - http_ssl_module
47
+ modules3rds:
48
+ -
49
+ name: ngx_cache_purge
50
+ form: git
51
+ url: https://github.com/FRiCKLE/ngx_cache_purge.git
52
+ rev: 2.3
53
+ configure_path: /usr/local/nginx_build/configure.sh
54
+ modules3rd_path: /usr/local/nginx_build/modules3rd.ini
55
+ ```
56
+
57
+ ## Contributing
58
+
59
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/itamae-plugin-recipe-nginx_build.
60
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "itamae/plugin/recipe/nginx/build"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'itamae/plugin/recipe/nginx_build/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "itamae-plugin-recipe-nginx_build"
8
+ spec.version = Itamae::Plugin::Recipe::NginxBuild::VERSION
9
+ spec.authors = ["zaru"]
10
+ spec.email = ["zarutofu@gmail.com"]
11
+
12
+ spec.summary = %q{Itamae plugin to install nginx-build}
13
+ spec.description = %q{Itamae plugin to install nginx-build}
14
+ spec.homepage = "https://github.com/zaru/itamae-plugin-recipe-nginx_build"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "itamae", "~> 1"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.10"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec"
26
+ end
@@ -0,0 +1,26 @@
1
+ require "itamae/plugin/recipe/nginx_build/version"
2
+
3
+ nginx_build_platform = "linux"
4
+ nginx_build_platform = node[:nginx_build][:platform] if node[:nginx_build] && node[:nginx_build][:platform]
5
+
6
+ nginx_build_version = "0.6.4"
7
+ nginx_build_version = node[:nginx_build][:version] if node[:nginx_build] && node[:nginx_build][:version]
8
+
9
+ nginx_build_bin = "/usr/local/bin/"
10
+ nginx_build_bin = node[:nginx_build][:bin] if node[:nginx_build] && node[:nginx_build][:bin]
11
+
12
+ %w(pcre pcre-devel).each do |pkg|
13
+ package pkg
14
+ end
15
+
16
+ execute "nginx-build install" do
17
+ nginx_build = <<"EOS"
18
+ cd /tmp && \
19
+ wget https://github.com/cubicdaiya/nginx-build/releases/download/v#{nginx_build_version}/nginx-build-#{nginx_build_platform}-amd64-#{nginx_build_version}.tar.gz && \
20
+ tar zxvf nginx-build-#{nginx_build_platform}-amd64-#{nginx_build_version}.tar.gz && \
21
+ rm -rf nginx-build-#{nginx_build_platform}-amd64-#{nginx_build_version}.tar.gz
22
+ mv nginx-build #{nginx_build_bin}
23
+ EOS
24
+ command nginx_build
25
+ not_if "test -e #{nginx_build_bin}nginx-build"
26
+ end
@@ -0,0 +1,87 @@
1
+ nginx_build_bin = "/usr/local/bin/"
2
+ nginx_build_bin = node[:nginx_build][:bin] if node[:nginx_build] && node[:nginx_build][:bin]
3
+
4
+ nginx_user = "nginx"
5
+ nginx_user = node[:nginx_build][:nginx_user] if node[:nginx_build] && node[:nginx_build][:nginx_user]
6
+
7
+ nginx_group = "nginx"
8
+ nginx_group = node[:nginx_build][:nginx_group] if node[:nginx_build] && node[:nginx_build][:nginx_group]
9
+
10
+ nginx_sbin = "/usr/sbin/nginx"
11
+ nginx_sbin = node[:nginx_build][:nginx_sbin] if node[:nginx_build] && node[:nginx_build][:nginx_sbin]
12
+
13
+ nginx_conf = "/etc/nginx/nginx.conf"
14
+ nginx_conf = node[:nginx_build][:nginx_conf] if node[:nginx_build] && node[:nginx_build][:nginx_conf]
15
+
16
+ nginx_pid = "/var/run/nginx.pid"
17
+ nginx_pid = node[:nginx_build][:nginx_pid] if node[:nginx_build] && node[:nginx_build][:nginx_pid]
18
+
19
+ nginx_modules = %w(http_ssl_module)
20
+ nginx_modules = node[:nginx_build][:modules] if node[:nginx_build] && node[:nginx_build][:modules]
21
+
22
+ configure_path = '/usr/local/nginx_build/configure.sh'
23
+ configure_path = node[:nginx_build][:configure_path] if node[:nginx_build] && node[:nginx_build][:configure_path]
24
+
25
+ modules3rd_path = '/usr/local/nginx_build/modules3rd.ini'
26
+ modules3rd_path = node[:nginx_build][:modules3rd_path] if node[:nginx_build] && node[:nginx_build][:modules3rd_path]
27
+
28
+ nginx_modules3rds = []
29
+ nginx_modules3rds = node[:nginx_build][:modules3rds] if node[:nginx_build] && node[:nginx_build][:modules3rds]
30
+
31
+ nginx_version = "1.8.0"
32
+ nginx_version = node[:nginx_build][:nginx_version] if node[:nginx_build] && node[:nginx_build][:nginx_version]
33
+
34
+ if configure_path =~ /^(.+)\/([^\/]+)$/
35
+ directory $1
36
+
37
+ template configure_path do
38
+ source "./templates/configure.sh.erb"
39
+ variables({
40
+ "nginx_user" => nginx_user,
41
+ "nginx_group" => nginx_group,
42
+ "nginx_sbin" => nginx_sbin,
43
+ "nginx_conf" => nginx_conf,
44
+ "nginx_pid" => nginx_pid,
45
+ "nginx_modules" => nginx_modules
46
+ })
47
+
48
+ notifies :run, 'execute[build-nginx]'
49
+ end
50
+
51
+ end
52
+
53
+ if modules3rd_path =~ /^(.+)\/([^\/]+)$/
54
+ directory $1
55
+
56
+ template modules3rd_path do
57
+ source "./templates/modules3rd.ini.erb"
58
+ variables({
59
+ "nginx_modules3rds" => nginx_modules3rds
60
+ })
61
+
62
+ notifies :run, 'execute[build-nginx]'
63
+ end
64
+
65
+ end
66
+
67
+ execute "build-nginx" do
68
+ command "#{nginx_build_bin}nginx-build -d work -v #{nginx_version} -c #{configure_path} -m #{modules3rd_path}"
69
+ command "cd ~/work/nginx/#{nginx_version}/nginx-#{nginx_version} && sudo make install"
70
+ action :nothing
71
+ end
72
+
73
+ template "/etc/init.d/nginx" do
74
+ owner "root"
75
+ group "root"
76
+ mode "755"
77
+ source "./templates/init_nginx.erb"
78
+ variables({
79
+ "nginx_sbin" => nginx_sbin,
80
+ "nginx_conf" => nginx_conf,
81
+ "nginx_pid" => nginx_pid,
82
+ })
83
+ end
84
+
85
+ service 'nginx' do
86
+ action [:enable, :start]
87
+ end
@@ -0,0 +1,9 @@
1
+ #!/bin/sh
2
+
3
+ ./configure \
4
+ --user=<%=@nginx_user%> \
5
+ --group=<%=@nginx_group%> \
6
+ --sbin-path=<%=@nginx_sbin%> \
7
+ --conf-path=<%=@nginx_conf%> \
8
+ --pid-path=<%=@nginx_pid%> \
9
+ <% @nginx_modules.each {|m| %> --with-<%=m%> <% } %>
@@ -0,0 +1,129 @@
1
+ #!/bin/sh
2
+ #
3
+ # nginx - this script starts and stops the nginx daemon
4
+ #
5
+ # chkconfig: - 85 15
6
+ # description: NGINX is an HTTP(S) server, HTTP(S) reverse \
7
+ # proxy and IMAP/POP3 proxy server
8
+ # processname: nginx
9
+ # config: <%=@nginx_conf%>
10
+ # config: /etc/sysconfig/nginx
11
+ # pidfile: <%=@nginx_pid%>
12
+
13
+ # Source function library.
14
+ . /etc/rc.d/init.d/functions
15
+
16
+ # Source networking configuration.
17
+ . /etc/sysconfig/network
18
+
19
+ # Check that networking is up.
20
+ [ "$NETWORKING" = "no" ] && exit 0
21
+
22
+ nginx="<%=@nginx_sbin%>"
23
+ prog=$(basename $nginx)
24
+
25
+ NGINX_CONF_FILE="<%=@nginx_conf%>"
26
+
27
+ [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
28
+
29
+ lockfile=/var/lock/subsys/nginx
30
+
31
+ make_dirs() {
32
+ # make required directories
33
+ user=`$nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
34
+ if [ -z "`grep $user /etc/passwd`" ]; then
35
+ useradd -M -s /bin/nologin $user
36
+ fi
37
+ options=`$nginx -V 2>&1 | grep 'configure arguments:'`
38
+ for opt in $options; do
39
+ if [ `echo $opt | grep '.*-temp-path'` ]; then
40
+ value=`echo $opt | cut -d "=" -f 2`
41
+ if [ ! -d "$value" ]; then
42
+ # echo "creating" $value
43
+ mkdir -p $value && chown -R $user $value
44
+ fi
45
+ fi
46
+ done
47
+ }
48
+
49
+ start() {
50
+ [ -x $nginx ] || exit 5
51
+ [ -f $NGINX_CONF_FILE ] || exit 6
52
+ make_dirs
53
+ echo -n $"Starting $prog: "
54
+ daemon $nginx -c $NGINX_CONF_FILE
55
+ retval=$?
56
+ echo
57
+ [ $retval -eq 0 ] && touch $lockfile
58
+ return $retval
59
+ }
60
+
61
+ stop() {
62
+ echo -n $"Stopping $prog: "
63
+ killproc $prog -QUIT
64
+ retval=$?
65
+ echo
66
+ [ $retval -eq 0 ] && rm -f $lockfile
67
+ return $retval
68
+ }
69
+
70
+ restart() {
71
+ configtest || return $?
72
+ stop
73
+ sleep 1
74
+ start
75
+ }
76
+
77
+ reload() {
78
+ configtest || return $?
79
+ echo -n $"Reloading $prog: "
80
+ killproc $nginx -HUP
81
+ RETVAL=$?
82
+ echo
83
+ }
84
+
85
+ force_reload() {
86
+ restart
87
+ }
88
+
89
+ configtest() {
90
+ $nginx -t -c $NGINX_CONF_FILE
91
+ }
92
+
93
+ rh_status() {
94
+ status $prog
95
+ }
96
+
97
+ rh_status_q() {
98
+ rh_status >/dev/null 2>&1
99
+ }
100
+
101
+ case "$1" in
102
+ start)
103
+ rh_status_q && exit 0
104
+ $1
105
+ ;;
106
+ stop)
107
+ rh_status_q || exit 0
108
+ $1
109
+ ;;
110
+ restart|configtest)
111
+ $1
112
+ ;;
113
+ reload)
114
+ rh_status_q || exit 7
115
+ $1
116
+ ;;
117
+ force-reload)
118
+ force_reload
119
+ ;;
120
+ status)
121
+ rh_status
122
+ ;;
123
+ condrestart|try-restart)
124
+ rh_status_q || exit 0
125
+ ;;
126
+ *)
127
+ echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
128
+ exit 2
129
+ esac
@@ -0,0 +1,7 @@
1
+ <% @nginx_modules3rds.each do |m| %>
2
+ [<%=m[:name]%>]
3
+ form=<%=m[:form]%>
4
+ url=<%=m[:url]%>
5
+ rev=<%=m[:rev]%>
6
+
7
+ <% end %>
@@ -0,0 +1,9 @@
1
+ module Itamae
2
+ module Plugin
3
+ module Recipe
4
+ module NginxBuild
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: itamae-plugin-recipe-nginx_build
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - zaru
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-12-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: itamae
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Itamae plugin to install nginx-build
70
+ email:
71
+ - zarutofu@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - README.md
81
+ - Rakefile
82
+ - bin/console
83
+ - bin/setup
84
+ - itamae-plugin-recipe-nginx_build.gemspec
85
+ - lib/itamae/plugin/recipe/nginx_build.rb
86
+ - lib/itamae/plugin/recipe/nginx_build/install.rb
87
+ - lib/itamae/plugin/recipe/nginx_build/templates/configure.sh.erb
88
+ - lib/itamae/plugin/recipe/nginx_build/templates/init_nginx.erb
89
+ - lib/itamae/plugin/recipe/nginx_build/templates/modules3rd.ini.erb
90
+ - lib/itamae/plugin/recipe/nginx_build/version.rb
91
+ homepage: https://github.com/zaru/itamae-plugin-recipe-nginx_build
92
+ licenses: []
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.4.5.1
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Itamae plugin to install nginx-build
114
+ test_files: []