summaryrefslogtreecommitdiff
path: root/manifests
diff options
context:
space:
mode:
authordrebs <drebs@riseup.net>2010-02-16 01:12:47 -0200
committerdrebs <drebs@riseup.net>2010-02-16 01:12:47 -0200
commit671780fbbb5fcc8f03c1f72386f31fc7c51080a9 (patch)
tree15d0b64a6371963d24e61252edca7f63a0a2f17b /manifests
parent74ccc5f671a6ab6434a64fc22809f1ddae44ea7e (diff)
downloadpuppet-nginx-671780fbbb5fcc8f03c1f72386f31fc7c51080a9.tar.gz
puppet-nginx-671780fbbb5fcc8f03c1f72386f31fc7c51080a9.tar.bz2
Splitting into smaller classes and adding puppetmaster proxying support.
Diffstat (limited to 'manifests')
-rw-r--r--manifests/init.pp73
1 files changed, 48 insertions, 25 deletions
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 <http://www.gnu.org/licenses/>.
-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"],
- }
}
}