Skip to content

Commit

Permalink
Rough sketch of Nginx & FPM based module
Browse files Browse the repository at this point in the history
  • Loading branch information
thsutton committed May 4, 2012
0 parents commit 2f1ed08
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Modulefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name 'thsutton-nginx'
author 'thsutton'
description 'Install and configure Nginx.'
summary 'Install and configure Nginx.'
license 'BSD3'
source 'https://github.com/thsutton/puppet-tomcat.git'
project_page ''
version '0.0.1'
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Puppet Module: Drupal
=====================

This module makes it straightforward to configure Nginx, PHP FPM and
MySQL to host Drupal web-sites. Its Nginx configuration is based on
that of the Aegir hosting platform, and includes support for several
popular Drupal modules.

21 changes: 21 additions & 0 deletions manifests/configuration.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# = Class: drupal::configuration
#
# This class creates the Drupal-specific configuration files for use
# by Nginx vhosts, etc.
#
# == Requires
#
# Nothing
#
# == Sample Usage:
#
# class { 'drupal::configuration' :
# include_support => ['ad'],
# }
#
class drupal::configuration ( $include_support = [] ) {
file { '/etc/nginx/drupal-site.conf' :
ensure => present,
content = template('drupal/nginx-drupal.erb'),
}
}
30 changes: 30 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#
# = Class: drupal
#
# Install and configure services to host Drupal sites.
#
# == Requires:
#
# thsutton-nginx
# thsutton-mysql
# thsutton-php
#
# == Sample Usage:
#
# include drupal
#
class drupal {

include nginx
include php::fpm
include mysql::server

# php::extension { 'apc' : ensure => present }
# php::extension { 'gd' : ensure => present }
# php::extension { 'mysql' : ensure => present }

# php::fpm::pool { 'www' : ensure => absent }
# php::fpm::pool { 'drupal': ensure => present }

include drupal::configuration
}
63 changes: 63 additions & 0 deletions manifests/site.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

# == Sample Usage:
#
# drupal::site { 'robocop' :
# ensure => present,
# path => '/var/www/robocop/',
# dbhost => 'db1.ocp.com',
# dbname => 'robocop_site',
# dbuser => 'robocop',
# dbpass => 'robopass',
# pool => 'ocp',
# }
#
define drupal::site (
$ensure => present
, $path
, $dbname
, $dbuser
, $dbpass
, $dbhost = 'localhost'
, $pool = 'www'
, $ssl = undef
) {

case $ensure {
'present' : {
# Require File[$path]

# Require Php::Fpm::Pool[$pool]
}
}

# MySQL configuration
mysql_user { "$dbuser@$dbhost" :
ensure => $ensure,
password => mysql_hash($dbpass)
}
mysql_database { "$dbhost/$dbname" :
ensure => $ensure,
}
mysql_grant { "$dbuser@$dbhost/$dbname"
ensure => $ensure,
privileges => all
}

file { "/etc/nginx/sites-available/drupal-$title" :
ensure => $ensure,
content => template('drupal/nginx-site.erb'),
}

file { "/etc/nginx/sites-enabled/drupal-$title" :
ensure => $ensure ? {
enabled, present => 'link',
default => 'absent',
},
target => "/etc/nginx/sites-available/drupal-$title",
require => File["/etc/nginx/sites-available/drupal-$title"],
notify => Class['nginx::service'],
}

Class['drupal::configuration'] -> Defined::Type["$title"]
}

13 changes: 13 additions & 0 deletions templates/nginx-drupal.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
###
### THIS FILE IS MANAGED BY PUPPET
###

#
# This file contains Drupal-specific configuration directives which
# should be included directly within the server block for a Drupal
# site.
#
# This file is based on the similar file generated by the Aegir
# project.
#

27 changes: 27 additions & 0 deletions templates/nginx-site.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
##
## THIS FILE IS MANAGED BY PUPPET!
##

server {
listen *;
root <%= path %>;

index index.php index.html;
server_name <%= "hello" %>;

location @drupal {
fastcgi_pass 127.0.0.1:9000;
}

#error_page 404 /404.html;
#location = /404.html {
# root /usr/share/nginx/www;
#}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}

# include <% drupal_path %>;
}

0 comments on commit 2f1ed08

Please sign in to comment.