2014-10-20 10:59:16 +02:00
|
|
|
{% from "nginx/map.jinja" import nginx as nginx_map with context %}
|
2014-10-18 07:33:57 +02:00
|
|
|
{% set nginx = pillar.get('nginx', {}) -%}
|
2018-12-20 12:37:03 +01:00
|
|
|
{% set home = nginx.get('home', nginx_map.home) -%}
|
|
|
|
{% set conf_dir = nginx.get('conf_dir', nginx_map.conf_dir) -%}
|
2014-10-18 07:33:57 +02:00
|
|
|
{% set conf_template = nginx.get('conf_template', 'salt://nginx/templates/config.jinja') -%}
|
|
|
|
|
|
|
|
{{ home }}:
|
|
|
|
file:
|
|
|
|
- directory
|
2014-10-20 10:59:16 +02:00
|
|
|
- user: {{ nginx_map.default_user }}
|
2014-10-20 17:01:51 +02:00
|
|
|
- group: {{ nginx_map.default_group }}
|
2014-10-18 07:33:57 +02:00
|
|
|
- mode: 0755
|
|
|
|
- makedirs: True
|
2015-09-27 19:09:57 +02:00
|
|
|
- require:
|
|
|
|
{%- if pillar.get('nginx', {}).get('install_from_source', false) %}
|
|
|
|
- user: {{ nginx_map.default_user }}
|
|
|
|
- group: {{ nginx_map.default_group }}
|
|
|
|
{%- else %}
|
|
|
|
- pkg: nginx
|
|
|
|
{% endif %}
|
2014-10-18 07:33:57 +02:00
|
|
|
|
2013-08-21 21:01:51 +02:00
|
|
|
/usr/share/nginx:
|
|
|
|
file:
|
|
|
|
- directory
|
|
|
|
|
|
|
|
{% for filename in ('default', 'example_ssl') %}
|
2014-10-18 07:33:57 +02:00
|
|
|
{{ conf_dir }}/conf.d/{{ filename }}.conf:
|
2013-08-21 21:01:51 +02:00
|
|
|
file.absent
|
|
|
|
{% endfor %}
|
|
|
|
|
2014-10-18 07:33:57 +02:00
|
|
|
{{ conf_dir }}:
|
2013-08-21 21:01:51 +02:00
|
|
|
file.directory:
|
|
|
|
- user: root
|
|
|
|
- group: root
|
2014-10-18 07:33:57 +02:00
|
|
|
- makedirs: True
|
2013-08-21 21:01:51 +02:00
|
|
|
|
2014-10-18 07:33:57 +02:00
|
|
|
{{ conf_dir }}/nginx.conf:
|
2013-08-21 21:01:51 +02:00
|
|
|
file:
|
|
|
|
- managed
|
|
|
|
- template: jinja
|
|
|
|
- user: root
|
|
|
|
- group: root
|
2014-10-18 07:33:57 +02:00
|
|
|
- mode: 644
|
|
|
|
- source: {{ conf_template }}
|
2013-08-21 21:01:51 +02:00
|
|
|
- require:
|
2014-10-18 07:33:57 +02:00
|
|
|
- file: {{ conf_dir }}
|
2014-10-20 10:59:16 +02:00
|
|
|
- context:
|
2019-04-11 15:02:18 +02:00
|
|
|
default_user: {{ nginx_map.default_user }}
|
|
|
|
default_group: {{ nginx_map.default_group }}
|
2014-10-20 10:59:16 +02:00
|
|
|
|
2014-10-31 17:08:50 +01:00
|
|
|
{% if nginx.get('init_conf_dirs', True) %}
|
2014-10-20 10:59:16 +02:00
|
|
|
{% for dir in ('sites-enabled', 'sites-available') %}
|
2014-10-31 17:08:50 +01:00
|
|
|
{{ conf_dir }}/{{ dir }}:
|
2014-10-20 10:59:16 +02:00
|
|
|
file.directory:
|
|
|
|
- user: root
|
|
|
|
- group: root
|
|
|
|
{% endfor -%}
|
2014-10-31 17:08:50 +01:00
|
|
|
{% endif %}
|