init feature add

pull/94/head
Michael Palmer 7 years ago
parent 10548f1909
commit 75a2372b14
  1. 5
      defaults/main.yml
  2. 3
      tasks/main.yml
  3. 21
      tasks/stream.yml
  4. 6
      templates/nginx.conf.j2
  5. 7
      templates/streams.j2
  6. 1
      vars/Debian.yml

@ -64,6 +64,11 @@ nginx_vhosts: []
# error_log: ""
# extra_parameters: "" # Can be used to add extra config blocks (multiline).
nginx_streams_filename: "streams.conf"
nginx_streams: []
# Example stream below. only available option is extra_parameters.
# - extra_parameters: "" # Can be used to add extra config blocks (multiline).
nginx_upstreams: []
# - name: myapp1
# strategy: "ip_hash" # "least_conn", etc.

@ -27,6 +27,9 @@
# Vhost configuration.
- include: vhosts.yml
# Stream configuration
- include: stream.yml
# Nginx setup.
- name: Copy nginx configuration in place.
template:

@ -0,0 +1,21 @@
---
- name: Ensure nginx_stream_path exists.
file:
path: "{{ nginx_stream_path }}"
state: directory
notify: reload nginx
- name: Add managed stream config file (if any streams are configured).
template:
src: streams.j2
dest: "{{ nginx_stream_path }}/{{ nginx_streams_filename }}"
mode: 0644
when: nginx_streams|length > 0
notify: reload nginx
- name: Remove managed stream config file (if no streams are configured).
file:
path: "{{ nginx_stream_path }}/{{ nginx_streams_filename }}"
state: absent
when: nginx_streams|length == 0
notify: reload nginx

@ -14,6 +14,12 @@ events {
{{ nginx_extra_conf_options }}
{% endif %}
{% if nginx_stream_path %}
stream {
include {{ nginx_stream_path }}/*;
}
{% endif %}
http {
include {{ nginx_mime_file_path }};
default_type application/octet-stream;

@ -0,0 +1,7 @@
{% for stream in nginx_streams %}
server {
{% if stream.extra_parameters is defined %}
{{ stream.extra_parameters|indent(4) }}
{% endif %}
}
{% endfor %}

@ -4,6 +4,7 @@ nginx_conf_path: /etc/nginx/conf.d
nginx_conf_file_path: /etc/nginx/nginx.conf
nginx_mime_file_path: /etc/nginx/mime.types
nginx_pidfile: /run/nginx.pid
nginx_stream_path: /etc/nginx/stream-enabled
nginx_vhost_path: /etc/nginx/sites-enabled
nginx_default_vhost_path: /etc/nginx/sites-enabled/default
__nginx_user: "www-data"