diff options
-rw-r--r-- | manifests/base.pp | 55 | ||||
-rw-r--r-- | manifests/cache.pp | 16 | ||||
-rw-r--r-- | manifests/site.pp | 48 | ||||
-rw-r--r-- | templates/nginx.conf.erb | 3 |
4 files changed, 64 insertions, 58 deletions
diff --git a/manifests/base.pp b/manifests/base.pp index d47d1fa..7febb79 100644 --- a/manifests/base.pp +++ b/manifests/base.pp @@ -10,11 +10,6 @@ class nginx::base { group => "root", } - # Caching - file { '/var/cache/nginx': - ensure => directory, - } - service { "nginx": enable => true, ensure => running, @@ -22,56 +17,6 @@ class nginx::base { require => [ Package["nginx"], File['/var/cache/nginx'] ], } - define site($ensure = present, $source = 'file') { - # Proxy config file - case $source { - 'file': { - file { "/etc/nginx/sites-available/$name": - source => "puppet:///modules/site_nginx/$name", - owner => "root", - group => "root", - mode => 0644, - ensure => $ensure, - notify => Service["nginx"], - require => File["/etc/nginx/sites-available"], - } - } - 'template': { - file { "/etc/nginx/sites-available/$name": - content => template("nginx/$name.erb"), - owner => "root", - group => "root", - mode => 0644, - ensure => $ensure, - notify => Service["nginx"], - require => File["/etc/nginx/sites-available"], - } - } - 'none': { - file { "/etc/nginx/sites-available/$name": - owner => "root", - group => "root", - mode => 0644, - ensure => $ensure, - notify => Service["nginx"], - require => File["/etc/nginx/sites-available"], - } - } - } - - $link = $ensure ? { - present => "/etc/nginx/sites-available/$name", - default => absent, - } - - # Symlink to enable proxy configuration - file { "/etc/nginx/sites-enabled/$name": - ensure => $link, - require => File["/etc/nginx/sites-enabled"], - notify => Service["nginx"], - } - } - # Main configuration file { "/etc/nginx/nginx.conf": content => template("nginx/nginx.conf.erb"), diff --git a/manifests/cache.pp b/manifests/cache.pp new file mode 100644 index 0000000..6ba4464 --- /dev/null +++ b/manifests/cache.pp @@ -0,0 +1,16 @@ +class nginx::cache { + file { '/var/cache/nginx': + ensure => directory, + } + + file { '/etc/nginx/conf.d/cache.conf' : + ensure => present, + owner => 'root', + group => 'root', + mode => '0644', + content => template('/etc/puppet/templates/template'), + content => "proxy_cache_path /var/cache/nginx/ levels=1:2 keys_zone=STATIC:10m inactive=24h max_size=1g;\n", + require => File['/var/cache/nginx'], + notify => Service['nginx'], + } +} diff --git a/manifests/site.pp b/manifests/site.pp new file mode 100644 index 0000000..1886f9b --- /dev/null +++ b/manifests/site.pp @@ -0,0 +1,48 @@ +define nginx::site($ensure = present, $source = 'file') { + case $source { + 'file': { + file { "/etc/nginx/sites-available/$name": + source => "puppet:///modules/site_nginx/$name", + owner => "root", + group => "root", + mode => 0644, + ensure => $ensure, + notify => Service["nginx"], + require => File["/etc/nginx/sites-available"], + } + } + 'template': { + file { "/etc/nginx/sites-available/$name": + content => template("nginx/$name.erb"), + owner => "root", + group => "root", + mode => 0644, + ensure => $ensure, + notify => Service["nginx"], + require => File["/etc/nginx/sites-available"], + } + } + 'none': { + file { "/etc/nginx/sites-available/$name": + owner => "root", + group => "root", + mode => 0644, + ensure => $ensure, + notify => Service["nginx"], + require => File["/etc/nginx/sites-available"], + } + } + } + + $link = $ensure ? { + present => "/etc/nginx/sites-available/$name", + default => absent, + } + + # Symlink to enable proxy configuration + file { "/etc/nginx/sites-enabled/$name": + ensure => $link, + require => File["/etc/nginx/sites-enabled"], + notify => Service["nginx"], + } +} diff --git a/templates/nginx.conf.erb b/templates/nginx.conf.erb index f4c24f0..cf339dd 100644 --- a/templates/nginx.conf.erb +++ b/templates/nginx.conf.erb @@ -29,9 +29,6 @@ http { gzip off; #gzip_disable "MSIE [1-6]\.(?!.*SV1)"; - # caching - proxy_cache_path /var/cache/nginx/ levels=1:2 keys_zone=STATIC:10m inactive=24h max_size=1g; - include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; |