summaryrefslogtreecommitdiff
path: root/manifests
diff options
context:
space:
mode:
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"],
- }
}
}