summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2016-06-17 12:15:35 -0300
committerSilvio Rhatto <rhatto@riseup.net>2016-06-17 12:15:35 -0300
commite9e704e1368f2d083298024554e0a06672f767ce (patch)
treea9279f603bd14a4e454ab8cc69b1f0b04e61441c
parentb1602fcad85d1c283d0f4da8d4166d3e17149344 (diff)
downloadpuppet-nginx-e9e704e1368f2d083298024554e0a06672f767ce.tar.gz
puppet-nginx-e9e704e1368f2d083298024554e0a06672f767ce.tar.bz2
Adds nginx::site::config
-rw-r--r--manifests/site.pp61
-rw-r--r--manifests/site/config.pp51
2 files changed, 65 insertions, 47 deletions
diff --git a/manifests/site.pp b/manifests/site.pp
index 543850c..448592d 100644
--- a/manifests/site.pp
+++ b/manifests/site.pp
@@ -1,60 +1,27 @@
define nginx::site(
$ensure = present,
+ $ssl = present,
$source = 'file',
$certbot = true
) {
- 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"],
+ nginx::site::config { $name:
+ ensure => $ensure,
+ source => $source,
}
if $certbot == true {
certbot::manage { $name:
- ensure => $ensure,
pre_hook => '/usr/sbin/service nginx restart',
- require => File["/etc/nginx/sites-enabled/$name"],
+ require => Nginx::Site[$name],
+ }
+ }
+
+ nginx::site::config { "${name}-ssl":
+ ensure => $ssl,
+ source => $source,
+ require => $certbot ? {
+ true => Certbot::Manage[$name],
+ default => undef,
}
}
}
diff --git a/manifests/site/config.pp b/manifests/site/config.pp
new file mode 100644
index 0000000..991a70b
--- /dev/null
+++ b/manifests/site/config.pp
@@ -0,0 +1,51 @@
+define nginx::site::config(
+ $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"],
+ }
+}