Browse Source

add support for streams

pull/276/head
Thomas Thorburn 4 years ago
parent
commit
e690655481
5 changed files with 52 additions and 0 deletions
  1. +3
    -0
      nginx/init.sls
  2. +14
    -0
      nginx/map.jinja
  3. +3
    -0
      nginx/passenger.sls
  4. +1
    -0
      nginx/servers_config.sls
  5. +31
    -0
      nginx/streams.sls

+ 3
- 0
nginx/init.sls View File

@@ -13,6 +13,9 @@ include:
{%- if nginx.snippets is defined %}
- nginx.snippets
{%- endif %}
{%- if nginx.streams is defined %}
- nginx.streams
{%- endif %}
- nginx.servers
- nginx.certificates


+ 14
- 0
nginx/map.jinja View File

@@ -16,6 +16,7 @@
'server_available': '/etc/nginx/sites-available',
'server_enabled': '/etc/nginx/sites-enabled',
'snippets_dir': '/etc/nginx/snippets',
'streams_dir': '/etc/nginx/streams',
'server_use_symlink': True,
'pid_file': '/run/nginx.pid',
'openssl_package': 'openssl',
@@ -30,6 +31,7 @@
'server_available': '/etc/nginx/conf.d',
'server_enabled': '/etc/nginx/conf.d',
'snippets_dir': '/etc/nginx/snippets',
'streams_dir': '/etc/nginx/streams',
'server_use_symlink': False,
'pid_file': '/run/nginx.pid',
'rh_os_releasever': '$releasever',
@@ -47,6 +49,7 @@
'server_available': '/etc/nginx/conf.d',
'server_enabled': '/etc/nginx/conf.d',
'snippets_dir': '/etc/nginx/snippets',
'streams_dir': '/etc/nginx/streams',
'server_use_symlink': False,
'pid_file': '/run/nginx.pid',
'rh_os_releasever': '$releasever',
@@ -67,6 +70,7 @@
'server_available': '/etc/nginx/vhosts.d',
'server_enabled': '/etc/nginx/vhosts.d',
'snippets_dir': '/etc/nginx/snippets',
'streams_dir': '/etc/nginx/streams',
'server_use_symlink': False,
'pid_file': '/run/nginx.pid',
'gpg_check': True,
@@ -81,6 +85,7 @@
'server_available': '/etc/nginx/sites-available',
'server_enabled': '/etc/nginx/sites-enabled',
'snippets_dir': '/etc/nginx/snippets',
'streams_dir': '/etc/nginx/streams',
'server_use_symlink': True,
'openssl_package': 'openssl',
},
@@ -92,6 +97,7 @@
'server_available': '/etc/nginx/sites-available',
'server_enabled': '/etc/nginx/sites-enabled',
'snippets_dir': '/etc/nginx/snippets',
'streams_dir': '/etc/nginx/streams',
'server_use_symlink': True,
'openssl_package': 'dev-libs/openssl',
},
@@ -104,6 +110,7 @@
'server_available': '/usr/local/etc/nginx/sites-available',
'server_enabled': '/usr/local/etc/nginx/sites-enabled',
'snippets_dir': '/usr/local/etc/nginx/snippets',
'streams_dir': '/usr/local/etc/nginx/streams',
'server_use_symlink': True,
'pid_file': '/var/run/nginx.pid',
},
@@ -132,6 +139,9 @@
'events': {
'worker_connections': 512,
},
'stream' : {
'include': '/etc/nginx/streams/*',
},
'http': {
'sendfile': 'on',
'tcp_nopush': 'on',
@@ -196,3 +206,7 @@
}) %}
{% endif %}
{% endif %}

{% if salt['grains.get']('os_family') == 'FreeBSD' %}
{% do nginx.server.config.stream.update({'include' : nginx.lookup.streams_dir ~ '/*'}) %}
{% endif %}

+ 3
- 0
nginx/passenger.sls View File

@@ -15,6 +15,9 @@ include:
{%- if nginx.snippets is defined %}
- nginx.snippets
{%- endif %}
{%- if nginx.streams is defined %}
- nginx.streams
{%- endif %}
- nginx.servers
- nginx.certificates


+ 1
- 0
nginx/servers_config.sls View File

@@ -11,6 +11,7 @@
{#- _nginx is a lightened copy of nginx map intended to passed in templates #}
{%- set _nginx = nginx.copy() %}
{%- do _nginx.pop('snippets') %}
{%- do _nginx.pop('streams') %}
{%- do _nginx.pop('servers') %}

# Simple path concatenation.

+ 31
- 0
nginx/streams.sls View File

@@ -0,0 +1,31 @@
# nginx.streams
#
# Manages creation of streams

{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ '/map.jinja' import nginx, sls_block with context %}
{%- from tplroot ~ '/libtofs.jinja' import files_switch with context %}

{#- _nginx is a lightened copy of nginx map intended to passed in templates #}
{%- set _nginx = nginx.copy() %}
{%- do _nginx.pop('streams') %}
{%- do _nginx.pop('servers') %}

nginx_streams_dir:
file.directory:
{{ sls_block(nginx.servers.dir_opts) }}
- name: {{ nginx.lookup.streams_dir }}

{% for stream, config in nginx.streams.items() %}
nginx_streams_{{ stream }}:
file.managed:
- name: {{ nginx.lookup.streams_dir ~ '/' ~ stream }}
- source: {{ files_switch([ stream, 'server.conf' ],
'nginx_stream_file_managed'
)
}}
- template: jinja
- context:
config: {{ config|json() }}
nginx: {{ _nginx|json() }}
{% endfor %}

Loading…
Cancel
Save