| OLD | NEW |
| 1 class nginx ( | 1 class nginx ( |
| 2 $worker_processes = $nginx::params::worker_processes, | 2 $worker_processes = $nginx::params::worker_processes, |
| 3 $worker_connections = $nginx::params::worker_connections, | 3 $worker_connections = $nginx::params::worker_connections, |
| 4 $ssl_session_cache = $nginx::params::ssl_session_cache | 4 $ssl_session_cache = $nginx::params::ssl_session_cache |
| 5 ) inherits nginx::params { | 5 ) inherits nginx::params { |
| 6 | 6 |
| 7 include apt | 7 include apt |
| 8 | 8 |
| 9 apt::source {'nginx': | 9 apt::source {'nginx': |
| 10 location => "http://nginx.org/packages/ubuntu", | 10 location => "http://nginx.org/packages/ubuntu", |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 file {'/etc/nginx/sites-available': | 39 file {'/etc/nginx/sites-available': |
| 40 ensure => directory, | 40 ensure => directory, |
| 41 require => Package['nginx'] | 41 require => Package['nginx'] |
| 42 } | 42 } |
| 43 | 43 |
| 44 file {'/etc/nginx/sites-enabled': | 44 file {'/etc/nginx/sites-enabled': |
| 45 ensure => directory, | 45 ensure => directory, |
| 46 require => Package['nginx'] | 46 require => Package['nginx'] |
| 47 } | 47 } |
| 48 | 48 |
| 49 file {'/etc/nginx/sites-available/default': | 49 define hostconfig ( |
| 50 ensure => absent, | 50 $domain = $title, |
| 51 require => Package['nginx'] | 51 $alt_names = [], |
| 52 } | 52 $log, |
| 53 $is_default = false, |
| 54 $source = undef, |
| 55 $content = undef, |
| 56 $global_config = undef, |
| 57 $certificate = undef, |
| 58 $private_key = undef, |
| 59 $enabled = true) { |
| 60 file {"/etc/nginx/sites-available/${domain}": |
| 61 ensure => file, |
| 62 content => template('nginx/site.erb'), |
| 63 require => Package['nginx'], |
| 64 notify => Service['nginx'], |
| 65 } |
| 53 | 66 |
| 54 define hostconfig ($file = $title, $source = undef, $content = undef, $enabled
= false) { | 67 if $certificate and $private_key { |
| 55 if $content != undef { | 68 if !defined(File["/etc/nginx/${certificate}"]) { |
| 56 file {"/etc/nginx/sites-available/${file}": | 69 file {"/etc/nginx/${certificate}": |
| 57 ensure => file, | 70 ensure => file, |
| 58 content => $content, | 71 mode => 0400, |
| 59 require => Package['nginx'], | 72 notify => Service['nginx'], |
| 60 notify => Service['nginx'], | 73 before => File["/etc/nginx/sites-available/${domain}"], |
| 74 require => Package['nginx'], |
| 75 source => "puppet:///modules/private/${certificate}" |
| 76 } |
| 77 } |
| 78 |
| 79 if !defined(File["/etc/nginx/${private_key}"]) { |
| 80 file {"/etc/nginx/${private_key}": |
| 81 ensure => file, |
| 82 mode => 0400, |
| 83 notify => Service['nginx'], |
| 84 before => File["/etc/nginx/sites-available/${domain}"], |
| 85 require => Package['nginx'], |
| 86 source => "puppet:///modules/private/${private_key}" |
| 87 } |
| 88 } |
| 89 |
| 90 if !defined(File["/etc/nginx/sites-available/${certificate}"]) { |
| 91 file {"/etc/nginx/sites-available/${certificate}": |
| 92 ensure => absent |
| 93 } |
| 94 } |
| 95 |
| 96 if !defined(File["/etc/nginx/sites-available/${private_key}"]) { |
| 97 file {"/etc/nginx/sites-available/${private_key}": |
| 98 ensure => absent |
| 99 } |
| 61 } | 100 } |
| 62 } | 101 } |
| 63 else { | 102 |
| 64 file {"/etc/nginx/sites-available/${file}": | 103 if $enabled == true { |
| 65 ensure => file, | 104 file {"/etc/nginx/sites-enabled/${domain}": |
| 66 source => $source, | 105 ensure => link, |
| 67 require => Package['nginx'], | 106 require => File["/etc/nginx/sites-available/${domain}"], |
| 68 notify => Service['nginx'], | 107 target => "/etc/nginx/sites-available/${domain}", |
| 108 notify => Service['nginx'] |
| 69 } | 109 } |
| 70 } | 110 } |
| 71 if $enabled == true { | 111 |
| 72 file {"/etc/nginx/sites-enabled/${file}": | 112 file {"/etc/logrotate.d/nginx_$domain": |
| 73 ensure => link, | 113 ensure => file, |
| 74 require => File["/etc/nginx/sites-available/${file}"], | 114 require => File["/etc/nginx/sites-available/${domain}"], |
| 75 target => "/etc/nginx/sites-available/${file}", | 115 content => template('nginx/logrotate.erb') |
| 76 notify => Service['nginx'] | |
| 77 } | |
| 78 } | 116 } |
| 79 } | 117 } |
| 80 | 118 |
| 81 file {'/etc/logrotate.d/nginx': | 119 file {'/etc/logrotate.d/nginx': |
| 82 source => 'puppet:///modules/nginx/logrotate', | 120 source => 'puppet:///modules/nginx/logrotate', |
| 83 require => Package['nginx'] | 121 require => Package['nginx'] |
| 84 } | 122 } |
| 85 | 123 |
| 86 service {'nginx': | 124 service {'nginx': |
| 87 ensure => running, | 125 ensure => running, |
| 88 enable => true, | 126 enable => true, |
| 89 restart => '/etc/init.d/nginx reload', | 127 restart => '/etc/init.d/nginx reload', |
| 90 hasstatus => true, | 128 hasstatus => true, |
| 91 require => File['/etc/nginx/nginx.conf'] | 129 require => File['/etc/nginx/nginx.conf'] |
| 92 } | 130 } |
| 93 } | 131 } |
| OLD | NEW |