fix(servers_config): remove service depedency
* servers_config should run without service dependency. Service is managed in servers.sls. * dropped nginx_service_reload in favor of extending nginx_service * wait for all file states (create and delete) * create dirs for symlinked files
This commit is contained in:
parent
8ea3c82be3
commit
05994e1b17
@ -5,12 +5,11 @@
|
|||||||
{%- set tplroot = tpldir.split('/')[0] %}
|
{%- set tplroot = tpldir.split('/')[0] %}
|
||||||
{%- from tplroot ~ '/map.jinja' import nginx, sls_block with context %}
|
{%- from tplroot ~ '/map.jinja' import nginx, sls_block with context %}
|
||||||
{%- from tplroot ~ '/servers_config.sls' import server_states with context %}
|
{%- from tplroot ~ '/servers_config.sls' import server_states with context %}
|
||||||
{%- from tplroot ~ '/service.sls' import service_function with context %}
|
|
||||||
|
|
||||||
{% macro file_requisites(states) %}
|
{% macro file_requisites(states) %}
|
||||||
{%- for state in states %}
|
{%- for state in states %}
|
||||||
- file: {{ state }}
|
- file: {{ state }}
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
include:
|
include:
|
||||||
@ -18,15 +17,12 @@ include:
|
|||||||
- nginx.servers_config
|
- nginx.servers_config
|
||||||
|
|
||||||
{% if server_states|length() > 0 %}
|
{% if server_states|length() > 0 %}
|
||||||
nginx_service_reload:
|
extend:
|
||||||
service.{{ service_function }}:
|
nginx_service:
|
||||||
- name: {{ nginx.lookup.service }}
|
service:
|
||||||
- reload: True
|
- reload: True
|
||||||
- use:
|
|
||||||
- service: nginx_service
|
|
||||||
- listen:
|
|
||||||
{{ file_requisites(server_states) }}
|
|
||||||
- require:
|
- require:
|
||||||
{{ file_requisites(server_states) }}
|
{{ file_requisites(server_states) }}
|
||||||
- service: nginx_service
|
- listen:
|
||||||
|
{{ file_requisites(server_states) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
file.symlink:
|
file.symlink:
|
||||||
{{ sls_block(nginx.servers.symlink_opts) }}
|
{{ sls_block(nginx.servers.symlink_opts) }}
|
||||||
- name: {{ server_path(server, state) }}
|
- name: {{ server_path(server, state) }}
|
||||||
|
- makedirs: True
|
||||||
- target: {{ server_path(server, anti_state) }}
|
- target: {{ server_path(server, anti_state) }}
|
||||||
{%- else %}
|
{%- else %}
|
||||||
{%- if deleted == True %}
|
{%- if deleted == True %}
|
||||||
@ -125,8 +126,6 @@ nginx_server_available_dir:
|
|||||||
}}
|
}}
|
||||||
- makedirs: True
|
- makedirs: True
|
||||||
- template: jinja
|
- template: jinja
|
||||||
- require_in:
|
|
||||||
- service: nginx_service
|
|
||||||
{% if 'source_path' not in settings.config %}
|
{% if 'source_path' not in settings.config %}
|
||||||
- context:
|
- context:
|
||||||
config: {{ settings.config|json(sort_keys=False) }}
|
config: {{ settings.config|json(sort_keys=False) }}
|
||||||
@ -136,9 +135,9 @@ nginx_server_available_dir:
|
|||||||
- unless:
|
- unless:
|
||||||
- test -e {{ server_curpath(server) }}
|
- test -e {{ server_curpath(server) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
{% do server_states.append(conf_state_id) %}
|
{% do server_states.append(conf_state_id) %}
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if settings.enabled != None %}
|
{% if settings.enabled != None %}
|
||||||
{% set status_state_id = 'server_state_' ~ loop.index0 %}
|
{% set status_state_id = 'server_state_' ~ loop.index0 %}
|
||||||
@ -156,9 +155,7 @@ nginx_server_available_dir:
|
|||||||
- file: {{ conf_state_id }}
|
- file: {{ conf_state_id }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if 'deleted' not in settings or ( 'deleted' in settings and settings.deleted == False ) %}
|
|
||||||
{% do server_states.append(status_state_id) %}
|
{% do server_states.append(status_state_id) %}
|
||||||
{% endif %}
|
|
||||||
{%- endif %} {# enabled != available_dir #}
|
{%- endif %} {# enabled != available_dir #}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
Loading…
Reference in New Issue
Block a user