Puppet Class: nginx

Defined in:
manifests/init.pp

Summary

Configure nginx sites

Overview

Parameters:

  • ports (Array[Integer]) (defaults to: [443])

    sets which ports to allow through the firewall for nginx

  • sites (Hash[String, Hash[String, Any]]) (defaults to: {})

    defines sites to create via hiera



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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'manifests/init.pp', line 5

class nginx (
  Array[Integer] $ports = [443],
  Hash[String, Hash[String, Any]] $sites = {},
) {
  package { 'nginx': }

  -> file { [
      '/etc/nginx',
      '/etc/nginx/ssl',
      '/etc/nginx/creds',
    ]:
      ensure => directory,
      owner  => 'root',
      group  => 'root',
      mode   => '0755',
  }

  file { '/etc/nginx/nginx.conf':
    ensure => file,
    source => 'puppet:///modules/nginx/nginx.conf',
    notify => Service['nginx'],
  }

  $sites.each |String $site, Hash $config| {
    nginx::site { $site:
      * => $config,
    }
  }

  file { '/etc/nginx/sites':
    ensure  => directory,
    owner   => 'root',
    group   => 'root',
    mode    => '0755',
    recurse => true,
    purge   => true,
    notify  => Service['nginx'],
  }

  $ports.each |Integer $port| {
    firewall { "100 allow inbound ${port} for nginx":
      dport  => $port,
      proto  => 'tcp',
      action => 'accept',
    }
  }

  service { 'nginx':
    ensure => running,
    enable => true,
  }
}