20110524 Work Snapshot
This commit is contained in:
Родитель
5d496f29e8
Коммит
3b036c95e5
|
@ -0,0 +1,11 @@
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
|
@ -0,0 +1,11 @@
|
||||||
|
name 'jfryman-nginx'
|
||||||
|
version '0.0.1'
|
||||||
|
source 'UNKNOWN'
|
||||||
|
author 'jfryman'
|
||||||
|
license 'UNKNOWN'
|
||||||
|
summary 'UNKNOWN'
|
||||||
|
description 'UNKNOWN'
|
||||||
|
project_page 'UNKNOWN'
|
||||||
|
|
||||||
|
## Add dependencies, if any:
|
||||||
|
# dependency 'username/name', '>= 1.2.0'
|
19
README
19
README
|
@ -0,0 +1,19 @@
|
||||||
|
nginx
|
||||||
|
|
||||||
|
This is the nginx module.
|
||||||
|
|
||||||
|
User Stories:
|
||||||
|
* Must be able to be used on a major linux system
|
||||||
|
- Ubuntu (LTS/Current)
|
||||||
|
- Debian (stable)
|
||||||
|
- CentOS/RHEL/Fedora
|
||||||
|
- SLES
|
||||||
|
- Solaris (optional goal)
|
||||||
|
* Must be able to install NGINX
|
||||||
|
- must have an option to perform a base install
|
||||||
|
- must have an option to install a PHP/MySQL Stack
|
||||||
|
- must have an option to install a Perl/MySQL stack
|
||||||
|
* Must be able to create a new vhost
|
||||||
|
- vhost must be able to be ssl enabled
|
||||||
|
- vhost must be able to point to N proxies
|
||||||
|
- vhost must be able to create a rewrite rule
|
|
@ -0,0 +1,22 @@
|
||||||
|
Files
|
||||||
|
=====
|
||||||
|
|
||||||
|
Puppet comes with both a client and server for copying files around. The file
|
||||||
|
serving function is provided as part of the central Puppet daemon,
|
||||||
|
puppetmasterd, and the client function is used through the source attribute of
|
||||||
|
file objects. Learn more at
|
||||||
|
http://projects.puppetlabs.com/projects/puppet/wiki/File_Serving_Configuration
|
||||||
|
|
||||||
|
You can use managed files like this:
|
||||||
|
|
||||||
|
class myclass {
|
||||||
|
package { mypackage: ensure => latest }
|
||||||
|
service { myservice: ensure => running }
|
||||||
|
file { "/etc/myfile":
|
||||||
|
source => "puppet://$servername/modules/mymodule/myfile"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
The files are searched for in:
|
||||||
|
|
||||||
|
$modulepath/mymodule/files/myfile
|
|
@ -0,0 +1,30 @@
|
||||||
|
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
|
Version: GnuPG v1.2.6 (GNU/Linux)
|
||||||
|
|
||||||
|
mQGiBEXopTIRBACZDBMOoFOakAjaxw1LXjeSvh/kmE35fU1rXfM7T0AV31NATCLF
|
||||||
|
l5CQiNDA4oWreDThg2Bf6+LIVTsGQb1V+XXuLak4Em5yTYwMTVB//4/nMxQEbpl/
|
||||||
|
QB2XwlJ7EQ0vW+kiPDz/7pHJz1p1jADzd9sQQicMtzysS4qT2i5A23j0VwCg1PB/
|
||||||
|
lpYqo0ZhWTrevxKMa1n34FcD/REavj0hSLQFTaKNLHRotRTF8V0BajjSaTkUT4uk
|
||||||
|
/RTaZ8Kr1mTosVtosqmdIAA2XHxi8ZLiVPPSezJjfElsSqOAxEKPL0djfpp2wrTm
|
||||||
|
l/1iVnX+PZH5DRKCbjdCMLDJhYap7YUhcPsMGSeUKrwmBCBJUPc6DhjFvyhA9IMl
|
||||||
|
1T0+A/9SKTv94ToP/JYoCTHTgnG5MoVNafisfe0wojP2mWU4gRk8X4dNGKMj6lic
|
||||||
|
vM6gne3hESyjcqZSmr7yELPPGhI9MNauJ6Ob8cTR2T12Fmv9w03DD3MnBstR6vhP
|
||||||
|
QcqZKhc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||||
|
GwwFCRLMAwAACgkQEZzANiF1IfZQYgCgiZHCv4xb+sTHCn/otc1Ovvi/OgMAnRXY
|
||||||
|
bbsLFWOfmzAnNIGvFRWy+YHi
|
||||||
|
=MMNL
|
||||||
|
-----END PGP PUBLIC KEY BLOCK-----
|
|
@ -0,0 +1,22 @@
|
||||||
|
Facter
|
||||||
|
======
|
||||||
|
|
||||||
|
Define facts in this directory.
|
||||||
|
|
||||||
|
Sometimes you need to be able to write conditional expressions based
|
||||||
|
on site-specific data that just isn’t available via Facter. The
|
||||||
|
solution may be to add a fact to Facter. These additional facts can
|
||||||
|
then be distributed to Puppet clients and are available for use in
|
||||||
|
manifests. Learn more at
|
||||||
|
http://projects.puppetlabs.com/projects/puppet/wiki/Adding_Facts
|
||||||
|
|
||||||
|
File paths should match the fact name; for example, a fact
|
||||||
|
`hardware_platform`, defined like this:
|
||||||
|
|
||||||
|
Facter.add("hardware_platform") do
|
||||||
|
setcode do
|
||||||
|
%x{/bin/uname -i}.chomp
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Should be found in `hardware_platform.rb` in this directory.
|
|
@ -0,0 +1,17 @@
|
||||||
|
Functions
|
||||||
|
=========
|
||||||
|
|
||||||
|
Define functions in this directory.
|
||||||
|
|
||||||
|
File paths should match the function name; for example, a function
|
||||||
|
`myfunction`, defined like this:
|
||||||
|
|
||||||
|
Puppet::Parser::Functions::newfunction(
|
||||||
|
:myfunction,
|
||||||
|
:type => :statement,
|
||||||
|
:doc => "Documentation here."
|
||||||
|
) do |vals|
|
||||||
|
# ...
|
||||||
|
end
|
||||||
|
|
||||||
|
Should be found in `myfunction.rb` in this directory.
|
|
@ -0,0 +1,14 @@
|
||||||
|
Providers
|
||||||
|
=========
|
||||||
|
|
||||||
|
Define providers under this directory.
|
||||||
|
|
||||||
|
File paths should match the resource type name and provider name; for
|
||||||
|
example, a provider `myprovider` for a resource type `mytype`, defined like this:
|
||||||
|
|
||||||
|
Puppet::Type.type(:mytype).provide(:myprovider) do
|
||||||
|
desc "Documentation here"
|
||||||
|
# ...
|
||||||
|
end
|
||||||
|
|
||||||
|
Should be found in `mytype/myprovider.rb` under this directory.
|
|
@ -0,0 +1,14 @@
|
||||||
|
Resource Types
|
||||||
|
==============
|
||||||
|
|
||||||
|
Define resource types in this directory.
|
||||||
|
|
||||||
|
Filenames should match the resource type name; for example, a resource
|
||||||
|
type `mytype`, defined like this:
|
||||||
|
|
||||||
|
Puppet::Type.newtype(:mytype) do
|
||||||
|
@doc = "Documentation here."
|
||||||
|
# ...
|
||||||
|
end
|
||||||
|
|
||||||
|
Should be found in `mytype.rb`
|
|
@ -0,0 +1,28 @@
|
||||||
|
Manifests
|
||||||
|
=========
|
||||||
|
|
||||||
|
Module manifest files belong in this directory.
|
||||||
|
|
||||||
|
`init.pp` defines how the module will carry out its tasks in this file.
|
||||||
|
|
||||||
|
Add additional definitions in this directory. Their file paths should match the
|
||||||
|
definition name; for example, a definition `mydefinition`, defined like this:
|
||||||
|
|
||||||
|
# Definition: mydefinition
|
||||||
|
#
|
||||||
|
# This is the mydefinition in the mymodule module.
|
||||||
|
#
|
||||||
|
# Parameters:
|
||||||
|
#
|
||||||
|
# Actions:
|
||||||
|
#
|
||||||
|
# Requires:
|
||||||
|
#
|
||||||
|
# Sample Usage:
|
||||||
|
#
|
||||||
|
# [Remember: No empty lines between comments and class definition]
|
||||||
|
define mydefinition {
|
||||||
|
# ...
|
||||||
|
}
|
||||||
|
|
||||||
|
Should be found in `mydefinition.pp` in this directory.
|
|
@ -0,0 +1,32 @@
|
||||||
|
class nginx::config {
|
||||||
|
$daemon_user = $operatingsystem ? {
|
||||||
|
/(debian|ubuntu)/ => 'www-data',
|
||||||
|
/(fedora|rhel|centos)/ => 'nginx',
|
||||||
|
}
|
||||||
|
user { $daemon_user:
|
||||||
|
ensure => present,
|
||||||
|
}
|
||||||
|
group { $daemon_user:
|
||||||
|
ensure => present,
|
||||||
|
}
|
||||||
|
file { '/etc/nginx/nginx.conf':
|
||||||
|
ensure => file,
|
||||||
|
owner => 'root',
|
||||||
|
group => 'root',
|
||||||
|
content => template('nginx/nginx.conf.erb'),
|
||||||
|
require => Class['nginx::install'],
|
||||||
|
notify => Class['nginx::service'],
|
||||||
|
}
|
||||||
|
file { '/etc/nginx/sites-available':
|
||||||
|
ensure => directory,
|
||||||
|
owner => 'root',
|
||||||
|
group => 'root',
|
||||||
|
require => Class['nginx::install'],
|
||||||
|
}
|
||||||
|
file { '/etc/nginx/sites-enabled':
|
||||||
|
ensure => directory,
|
||||||
|
owner => 'root',
|
||||||
|
group => 'root',
|
||||||
|
require => Class['nginx::install'],
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Class: nginx
|
||||||
|
#
|
||||||
|
# This module manages nginx
|
||||||
|
#
|
||||||
|
# Parameters:
|
||||||
|
#
|
||||||
|
# Actions:
|
||||||
|
#
|
||||||
|
# Requires:
|
||||||
|
#
|
||||||
|
# Sample Usage:
|
||||||
|
#
|
||||||
|
# [Remember: No empty lines between comments and class definition]
|
||||||
|
class nginx {
|
||||||
|
include nginx::service, nginx::install, nginx::config,
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
class nginix::install {
|
||||||
|
|
||||||
|
# prepopulating a potential install for non-Linux distros.
|
||||||
|
$package = $operatingsystem ? {
|
||||||
|
/(ubuntu|debian|centos|fedora|rhel)/ => 'nginx'
|
||||||
|
}
|
||||||
|
|
||||||
|
package { $package:
|
||||||
|
name => 'nginx',
|
||||||
|
ensure => installed,
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
# Defines a default install from package. Update as appropriate for base install.
|
||||||
|
#######################################################################
|
||||||
|
#
|
||||||
|
# This is the main Nginx configuration file.
|
||||||
|
#
|
||||||
|
# More information about the configuration options is available on
|
||||||
|
# * the English wiki - http://wiki.nginx.org/Main
|
||||||
|
# * the Russian documentation - http://sysoev.ru/nginx/
|
||||||
|
#
|
||||||
|
#######################################################################
|
||||||
|
|
||||||
|
class nginx::params {
|
||||||
|
$worker_processes = 1
|
||||||
|
$worker_connections = 1024
|
||||||
|
$multi_accept = off
|
||||||
|
$sendfile = on
|
||||||
|
$keepalive_timeout = 65
|
||||||
|
$tcp_nodelay = on
|
||||||
|
$gzip = on
|
||||||
|
|
||||||
|
# Setup OS Specific Logging Directories and PID files.
|
||||||
|
case $kernel {
|
||||||
|
default {
|
||||||
|
$log_dir = '/var/log/nginx'
|
||||||
|
$pid = '/var/run/nginx.pid'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
class nginix::service {
|
||||||
|
service { "nginx":
|
||||||
|
ensure => running,
|
||||||
|
enable => true,
|
||||||
|
hasstatus => true,
|
||||||
|
hasrestart => true,
|
||||||
|
require => Class['nginx::install'],
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
define nginx::vhost(
|
||||||
|
$listen = '*',
|
||||||
|
$listen_port,
|
||||||
|
$www_root,
|
||||||
|
$ssl = 'off',
|
||||||
|
$ssl_cert,
|
||||||
|
$ssl_key,
|
||||||
|
$location,
|
||||||
|
$state = 'enable',
|
||||||
|
) {
|
||||||
|
file { "/etc/nginx/sites-available/${name}":
|
||||||
|
ensure => file,
|
||||||
|
owner => 'root',
|
||||||
|
group => 'root',
|
||||||
|
mode => '0644',
|
||||||
|
content => template('nginx/vhost.erb')
|
||||||
|
}
|
||||||
|
file { "/etc/nginx/sites-enabled/${name}":
|
||||||
|
ensure => $state ? {
|
||||||
|
'disable' => absent,
|
||||||
|
default => 'symlink',
|
||||||
|
}
|
||||||
|
target => "/etc/nginx/sites-available/${name}",
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
/*
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
| |
|
||||||
|
| ==> DO NOT EDIT THIS FILE! <== |
|
||||||
|
| |
|
||||||
|
| You should edit the `Modulefile` and run `puppet-module build` |
|
||||||
|
| to generate the `metadata.json` file for your releases. |
|
||||||
|
| |
|
||||||
|
+-----------------------------------------------------------------------+
|
||||||
|
*/
|
||||||
|
|
||||||
|
{}
|
|
@ -0,0 +1,7 @@
|
||||||
|
Specs
|
||||||
|
=====
|
||||||
|
|
||||||
|
The Puppet project uses RSpec for testing.
|
||||||
|
|
||||||
|
For more information on RSpec, see http://rspec.info/
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
--format
|
||||||
|
s
|
||||||
|
--colour
|
||||||
|
--loadby
|
||||||
|
mtime
|
||||||
|
--backtrace
|
|
@ -0,0 +1,18 @@
|
||||||
|
require 'pathname'
|
||||||
|
dir = Pathname.new(__FILE__).parent
|
||||||
|
$LOAD_PATH.unshift(dir, dir + 'lib', dir + '../lib')
|
||||||
|
|
||||||
|
require 'mocha'
|
||||||
|
require 'puppet'
|
||||||
|
gem 'rspec', '=1.2.9'
|
||||||
|
require 'spec/autorun'
|
||||||
|
|
||||||
|
Spec::Runner.configure do |config|
|
||||||
|
config.mock_with :mocha
|
||||||
|
end
|
||||||
|
|
||||||
|
# We need this because the RAL uses 'should' as a method. This
|
||||||
|
# allows us the same behaviour but with a different method name.
|
||||||
|
class Object
|
||||||
|
alias :must :should
|
||||||
|
end
|
|
@ -0,0 +1,4 @@
|
||||||
|
Provider Specs
|
||||||
|
==============
|
||||||
|
|
||||||
|
Define specs for your providers under this directory.
|
|
@ -0,0 +1,4 @@
|
||||||
|
Resource Type Specs
|
||||||
|
===================
|
||||||
|
|
||||||
|
Define specs for your resource types in this directory.
|
|
@ -0,0 +1,23 @@
|
||||||
|
Templates
|
||||||
|
=========
|
||||||
|
|
||||||
|
Puppet supports templates and templating via ERB, which is part of the Ruby
|
||||||
|
standard library and is used for many other projects including Ruby on Rails.
|
||||||
|
Templates allow you to manage the content of template files, for example
|
||||||
|
configuration files that cannot yet be managed as a Puppet type. Learn more at
|
||||||
|
http://projects.puppetlabs.com/projects/puppet/wiki/Puppet_Templating
|
||||||
|
|
||||||
|
You can use templates like this:
|
||||||
|
|
||||||
|
class myclass {
|
||||||
|
package { mypackage: ensure => latest }
|
||||||
|
service { myservice: ensure => running }
|
||||||
|
file { "/etc/myfile":
|
||||||
|
content => template("mymodule/myfile.erb")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
The templates are searched for in:
|
||||||
|
|
||||||
|
$templatedir/mymodule/myfile.erb
|
||||||
|
$modulepath/mymodule/templates/myfile.erb
|
|
@ -0,0 +1,35 @@
|
||||||
|
user <%= scope.lookupvar('nginx::config::daemon_user') %>;
|
||||||
|
worker_processes <%= scope.lookupvar('nginx::params::worker_processes')%>;
|
||||||
|
|
||||||
|
error_log <%= scope.lookupvar('nginx::params::log_dir')%>/error.log;
|
||||||
|
pid <%= scope.lookupvar('nginx::params::pid')%>;
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections <%= scope.lookupvar('nginx::params::worker_connections') %>;
|
||||||
|
<% if scope.lookupvar('nginx::params::multi_accept' == 'on') %>
|
||||||
|
multi_accept on;
|
||||||
|
<% end %>
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
include /etc/nginx/mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
|
||||||
|
access_log <%= scope.lookupvar('nginx::params::log_dir')%>/access.log;
|
||||||
|
|
||||||
|
sendfile <%= scope.lookupvar('nginx::params::sendfile')%>;
|
||||||
|
<% if scope.lookupvar('nginx::params::tcp_nopush' == 'on') %>
|
||||||
|
tcp_nopush on;
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
keepalive_timeout <%= scope.lookupvar('nginx::params::keepalive_timeout')%>;
|
||||||
|
tcp_nodelay <%= scope.lookupvar('nginx::params::tcp_nodelay')%>;
|
||||||
|
|
||||||
|
<% if scope.lookupvar('nginx::params::gzip' == 'on') %>
|
||||||
|
gzip on;
|
||||||
|
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
include /etc/nginx/conf.d/*.conf;
|
||||||
|
include /etc/nginx/sites-enabled/*;
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
server {
|
||||||
|
|
||||||
|
listen <%= listen %>; ## listen for ipv4
|
||||||
|
listen [::]:80 default ipv6only=on; ## listen for ipv6
|
||||||
|
|
||||||
|
server_name <%= name %>;
|
||||||
|
|
||||||
|
access_log <%= scope.lookupvar('nginx::params::log_dir')%>/<%= name %>.access.log;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
root <%= www_root %>;
|
||||||
|
index index.html index.htm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
<% if ssl == 'on' %>
|
||||||
|
server {
|
||||||
|
listen 443;
|
||||||
|
server_name <%= name %>;
|
||||||
|
|
||||||
|
ssl on;
|
||||||
|
ssl_certificate <%= ssl_cert %>;
|
||||||
|
ssl_certificate_key <%= ssl_key %>;
|
||||||
|
|
||||||
|
ssl_session_timeout 5m;
|
||||||
|
|
||||||
|
ssl_protocols SSLv3 TLSv1;
|
||||||
|
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
|
||||||
|
ssl_prefer_server_ciphers on;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
root <%= www_root %>;
|
||||||
|
index index.html index.htm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<% end %>
|
|
@ -0,0 +1,2 @@
|
||||||
|
include nginx
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
include nginix
|
||||||
|
|
||||||
|
nginix::vhost { 'www.test.com':
|
||||||
|
port => '80',
|
||||||
|
webroot => "/opt/www/test",
|
||||||
|
ssl => false,
|
||||||
|
}
|
Загрузка…
Ссылка в новой задаче