summaryrefslogtreecommitdiff
path: root/manifests/site.pp
blob: f73ae30cd0450840ae828b0ffb9721c407ec20ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
define nginx::site(
  $ensure   = present,
  $ssl      = present,
  $source   = 'template',
  $certbot  = true,
  $template = 'site',
  $backend  = 'weblocal',
) {
  nginx::site::config { $name:
    ensure   => $ensure,
    source   => $source,
    template => $template,
    backend  => $backend,
  }

  if $certbot == true {
    certbot::manage { $name:
      pre_hook => '/usr/sbin/service nginx restart',
      require  => Nginx::Site::Config[$name],
    }
  }

  nginx::site::config { "${name}-ssl":
    use_fqdn  => $name,
    ensure    => $ssl,
    source    => $source,
    template  => "${template}-ssl",
    backend   => $backend,
    require   => $certbot ? {
      true    => Certbot::Manage[$name],
      default => undef,
    }
  }
}