From 671780fbbb5fcc8f03c1f72386f31fc7c51080a9 Mon Sep 17 00:00:00 2001 From: drebs Date: Tue, 16 Feb 2010 01:12:47 -0200 Subject: Splitting into smaller classes and adding puppetmaster proxying support. --- manifests/init.pp | 73 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 25 deletions(-) (limited to 'manifests') diff --git a/manifests/init.pp b/manifests/init.pp index 3482002..6d4711d 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -16,7 +16,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -class nginx { +# Base class +class nginx::base { $ssl = $nginx_ssl ? { false => false, @@ -33,6 +34,40 @@ class nginx { group => "root", } + service { "nginx": + enable => true, + ensure => running, + hasrestart => true, + require => [ File["/etc/nginx/sites-enabled/$domain"], Package["nginx"] ], + } + + define site($site = $domain, $ensure = present) { + # Proxy config file + file { "/etc/nginx/sites-available/$site": + source => "puppet://$server/files/etc/nginx/$site", + owner => "root", + group => "root", + mode => 0644, + ensure => $ensure, + notify => Service["nginx"], + require => File["/etc/nginx/sites-available"], + } + + $link = $ensure ? { + present => "/etc/nginx/sites-available/$site", + default => absent, + } + + # Symlink to enable proxy configuration + file { "/etc/nginx/sites-enabled/$site": + ensure => $link, + require => File["/etc/nginx/sites-enabled"], + notify => Service["nginx"], + } + } +} + +class nginx inherits nginx::base { if $ssl == true { file { [ "/etc/ssl", "/etc/ssl/certs", "/etc/ssl/private" ]: ensure => directory, @@ -58,47 +93,35 @@ class nginx { require => File["/etc/ssl/private"], } - service { "nginx": + Service { "nginx": enable => true, ensure => running, hasrestart => true, require => [ File["/etc/nginx/sites-enabled/$domain"], Package["nginx"], File["/etc/ssl/private/cert.pem"], File["/etc/ssl/certs/cert.crt"] ], } - } else { - service { "nginx": - enable => true, - ensure => running, - hasrestart => true, - require => [ File["/etc/nginx/sites-enabled/$domain"], Package["nginx"] ], - } } # Default site site { "$domain": ensure => present, } - define site($site = $domain, $ensure = present) { - # Proxy config file - file { "/etc/nginx/sites-available/$site": - source => "puppet://$server/files/etc/nginx/$site", +} + +class nginx::puppetmaster inherits nginx::base { + + define proxy($name, $worker_processes = 4, $worker_connections = 1024, + $ssl_port = 8140, $non_ssl_port = 8141, + $puppetmaster_servers = [ "127.0.0.1:18140", ]) { + + file { "/etc/nginx/sites-available/$name": + content => "puppetmaster.erb", owner => "root", group => "root", mode => 0644, - ensure => $ensure, + ensure => present, notify => Service["nginx"], require => File["/etc/nginx/sites-available"], } - $link = $ensure ? { - present => "/etc/nginx/sites-available/$site", - default => absent, - } - - # Symlink to enable proxy configuration - file { "/etc/nginx/sites-enabled/$site": - ensure => $link, - require => File["/etc/nginx/sites-enabled"], - notify => Service["nginx"], - } } } -- cgit v1.2.3