nginx-formula/nginx/service.sls

48 lines
1.2 KiB
Plaintext
Raw Normal View History

# nginx.service
2014-05-16 00:06:48 +02:00
#
# Manages the nginx service.
2014-05-19 19:22:51 +02:00
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ '/map.jinja' import nginx, sls_block with context %}
{%- from tplroot ~ '/libtofs.jinja' import files_switch with context %}
2014-05-16 00:06:48 +02:00
{% set service_function = {True:'running', False:'dead'}.get(nginx.service.enable) %}
include:
{% if nginx.install_from_source %}
- nginx.src
{% else %}
- nginx.pkg
{% endif %}
{% if nginx.install_from_source %}
nginx_systemd_service_file:
file.managed:
- name: /lib/systemd/system/nginx.service
- source: {{ files_switch(['nginx.service'],
'nginx_systemd_service_file'
)
}}
2017-12-12 21:10:51 +01:00
{% endif %}
2014-05-16 00:06:48 +02:00
nginx_service:
service.{{ service_function }}:
{{ sls_block(nginx.service.opts) }}
- name: {{ nginx.lookup.service }}
- enable: {{ nginx.service.enable }}
- require:
{% if nginx.install_from_source %}
- sls: nginx.src
{% else %}
- sls: nginx.pkg
{% endif %}
- listen:
{% if nginx.install_from_source %}
- cmd: nginx_install
{% else %}
2014-05-16 00:06:48 +02:00
- pkg: nginx_install
{% endif %}
{% if nginx.check_config_before_apply %}
- only_if: /usr/sbin/nginx -t
{% endif %}