Puppet Class: seed_stack::template_nginx

Inherits:
seed_stack::params
Defined in:
manifests/template_nginx.pp

Overview

Class: seed_stack::template_nginx

Installs Nginx and Consul Template as well as a Consul Template template for configuring Nginx load-balancing across upstream services.

Parameters

consul_template_version

The version of Consul Template to install.

consul_address

The address for the Consul agent for Consul Template to connect to.

Parameters:

  • consul_template_version (Any) (defaults to: $seed_stack::params::consul_template_version)
  • consul_address (Any) (defaults to: $seed_stack::params::consul_client_addr)


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
# File 'manifests/template_nginx.pp', line 13

class seed_stack::template_nginx (
  $consul_template_version = $seed_stack::params::consul_template_version,
  $consul_address          = $seed_stack::params::consul_client_addr,
) inherits seed_stack::params {
  validate_ip_address($consul_address)

  if ! defined (Package['unzip']) {
    package { 'unzip':
      ensure => installed,
    }
  }

  class { 'consul_template':
    version      => $consul_template_version,
    config_dir   => '/etc/consul-template',
    user         => 'root',
    group        => 'root',
    consul_host  => $consul_address,
    consul_port  => 8500,
    consul_retry => '10s',
    # For some reason, consul-template doesn't like this option.
    # consul_max_stale => '10m',
    log_level    => 'warn',
  }
  # FIXME: See gdhbashton/puppet-consul_template#61
  Package['unzip'] -> Class['consul_template::install']

  # Configure Nginx to load-balance across uptream services
  file { '/etc/consul-template/nginx-upstreams.ctmpl':
    source => 'puppet:///modules/seed_stack/nginx-upstreams.ctmpl',
  }
  ~>
  consul_template::watch { 'nginx-upstreams':
    source      => '/etc/consul-template/nginx-upstreams.ctmpl',
    destination => '/etc/nginx/sites-enabled/seed-upstreams.conf',
    command     => '/etc/init.d/nginx reload',
  }
}