Defined Type: nginx::resource::streamhost

Defined in:
manifests/resource/streamhost.pp

Summary

Create a virtual steamhost

Overview

Examples:

basic streamhost

nginx::resource::streamhost { 'test2.local':
  ensure   => present,
}

Parameters:

  • ensure (Enum['absent', 'present']) (defaults to: 'present')

    Enables or disables the specified streamhost

  • listen_ip (Variant[Array, String]) (defaults to: '*')

    Default IP Address for NGINX to listen with this streamhost on. Defaults to all interfaces (*)

  • listen_port (Integer) (defaults to: 80)

    Default TCP Port for NGINX to listen with this streamhost on.

  • listen_options (Optional[String]) (defaults to: undef)

    Extra options for listen directive like ‘default’ to catchall.

  • ipv6_enable (Boolean) (defaults to: false)

    Value to enable/disable IPv6 support Module will check to see if IPv6 support exists on your system before enabling.

  • ipv6_listen_ip (Variant[Array, String]) (defaults to: '::')

    Default IPv6 Address for NGINX to listen with this streamhost on. Defaults to all interfaces (::)

  • ipv6_listen_port (Integer) (defaults to: $listen_port)

    Default IPv6 Port for NGINX to listen with this streamhost on.

  • ipv6_listen_options (String) (defaults to: 'default ipv6only=on')

    Extra options for listen directive like ‘default’ to catchall.

  • proxy (Any) (defaults to: undef)

    Proxy server(s) for the root location to connect to. Accepts a single value, can be used in conjunction with nginx::resource::upstream

  • proxy_read_timeout (Optional[Nginx::Time]) (defaults to: $nginx::proxy_read_timeout)

    Override the default the proxy read timeout value of 90 seconds

  • resolver (Array) (defaults to: [])

    Configures name servers used to resolve names of upstream servers into addresses.

  • raw_prepend (Variant[Array[String], String]) (defaults to: [])

    A single string, or an array of strings to prepend to the server directive (after cfg prepend directives). NOTE: YOU are responsible for a semicolon on each line that requires one.

  • raw_append (Variant[Array[String], String]) (defaults to: [])

    A single string, or an array of strings to append to the server directive (after cfg append directives). NOTE: YOU are responsible for a semicolon on each line that requires one.

  • owner (String) (defaults to: $nginx::global_owner)

    Defines owner of the .conf file

  • group (String) (defaults to: $nginx::global_group)

    Defines group of the .conf file

  • mode (String) (defaults to: $nginx::global_mode)

    Defines mode of the .conf file Default to return 503

  • proxy_connect_timeout (Optional[Nginx::Time]) (defaults to: $nginx::proxy_connect_timeout)


51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'manifests/resource/streamhost.pp', line 51

define nginx::resource::streamhost (
  Enum['absent', 'present'] $ensure            = 'present',
  Variant[Array, String] $listen_ip            = '*',
  Integer $listen_port                         = 80,
  Optional[String] $listen_options             = undef,
  Boolean $ipv6_enable                         = false,
  Variant[Array, String] $ipv6_listen_ip       = '::',
  Integer $ipv6_listen_port                    = $listen_port,
  String $ipv6_listen_options                  = 'default ipv6only=on',
  $proxy                                       = undef,
  Optional[Nginx::Time]
  $proxy_read_timeout                          = $nginx::proxy_read_timeout,
  Optional[Nginx::Time]
  $proxy_connect_timeout                       = $nginx::proxy_connect_timeout,
  Array $resolver                              = [],
  Variant[Array[String], String] $raw_prepend  = [],
  Variant[Array[String], String] $raw_append   = [],
  String $owner                                = $nginx::global_owner,
  String $group                                = $nginx::global_group,
  String $mode                                 = $nginx::global_mode,
) {
  if ! defined(Class['nginx']) {
    fail('You must include the nginx base class before using any defined resources')
  }

  # Variables
  if $nginx::confd_only {
    $streamhost_dir = "${nginx::conf_dir}/conf.stream.d"
  } else {
    $streamhost_dir = "${nginx::conf_dir}/streams-available"
    $streamhost_enable_dir = "${nginx::conf_dir}/streams-enabled"
    $streamhost_symlink_ensure = $ensure ? {
      'absent' => absent,
      default  => 'link',
    }
  }

  $name_sanitized = regsubst($name, ' ', '_', 'G')
  $config_file = "${streamhost_dir}/${name_sanitized}.conf"

  # Add IPv6 Logic Check - Nginx service will not start if ipv6 is enabled
  # and support does not exist for it in the kernel.
  if $ipv6_enable and !$facts['networking']['ip6'] {
    warning('nginx: IPv6 support is not enabled or configured properly')
  }

  concat { $config_file:
    ensure  => $ensure,
    owner   => $owner,
    group   => $group,
    mode    => $mode,
    notify  => Class['nginx::service'],
    require => File[$streamhost_dir],
    tag     => 'nginx_config_file',
  }

  concat::fragment { "${name_sanitized}-header":
    target  => $config_file,
    content => template('nginx/streamhost/streamhost.erb'),
    order   => '001',
  }

  unless $nginx::confd_only {
    file { "${name_sanitized}.conf symlink":
      ensure  => $streamhost_symlink_ensure,
      path    => "${streamhost_enable_dir}/${name_sanitized}.conf",
      target  => $config_file,
      owner   => $owner,
      group   => $group,
      mode    => $mode,
      require => Concat[$config_file],
      notify  => Class['nginx::service'],
    }
  }
}