|
|
|
|
|
|
|
|
{%- endmacro %} |
|
|
{%- endmacro %} |
|
|
|
|
|
|
|
|
# Creates the sls block that manages symlinking / renaming servers |
|
|
# Creates the sls block that manages symlinking / renaming servers |
|
|
{% macro manage_status(server, state) -%} |
|
|
|
|
|
|
|
|
{% macro manage_status(server, state, deleted) -%} |
|
|
{%- set anti_state = {True:False, False:True}.get(state) -%} |
|
|
{%- set anti_state = {True:False, False:True}.get(state) -%} |
|
|
{% if state == True %} |
|
|
{% if state == True %} |
|
|
{%- if nginx.lookup.server_use_symlink %} |
|
|
{%- if nginx.lookup.server_use_symlink %} |
|
|
|
|
|
|
|
|
- name: {{ server_path(server, state) }} |
|
|
- name: {{ server_path(server, state) }} |
|
|
- target: {{ server_path(server, anti_state) }} |
|
|
- target: {{ server_path(server, anti_state) }} |
|
|
{%- else %} |
|
|
{%- else %} |
|
|
|
|
|
{%- if deleted == True %} |
|
|
|
|
|
file.absent: |
|
|
|
|
|
- name: {{ server_path(server, state) }} |
|
|
|
|
|
{%- else %} |
|
|
file.rename: |
|
|
file.rename: |
|
|
{{ sls_block(nginx.servers.rename_opts) }} |
|
|
{{ sls_block(nginx.servers.rename_opts) }} |
|
|
- name: {{ server_path(server, state) }} |
|
|
- name: {{ server_path(server, state) }} |
|
|
- source: {{ server_path(server, anti_state) }} |
|
|
- source: {{ server_path(server, anti_state) }} |
|
|
|
|
|
{%- endif %} |
|
|
{%- endif %} |
|
|
{%- endif %} |
|
|
{%- elif state == False %} |
|
|
{%- elif state == False %} |
|
|
{%- if nginx.lookup.server_use_symlink %} |
|
|
{%- if nginx.lookup.server_use_symlink %} |
|
|
file.absent: |
|
|
file.absent: |
|
|
- name: {{ server_path(server, anti_state) }} |
|
|
- name: {{ server_path(server, anti_state) }} |
|
|
{%- else %} |
|
|
{%- else %} |
|
|
|
|
|
{%- if deleted == True %} |
|
|
|
|
|
file.absent: |
|
|
|
|
|
- name: {{ server_path(server, state) }} |
|
|
|
|
|
{%- else %} |
|
|
file.rename: |
|
|
file.rename: |
|
|
{{ sls_block(nginx.servers.rename_opts) }} |
|
|
{{ sls_block(nginx.servers.rename_opts) }} |
|
|
- name: {{ server_path(server, state) }} |
|
|
- name: {{ server_path(server, state) }} |
|
|
- source: {{ server_path(server, anti_state) }} |
|
|
- source: {{ server_path(server, anti_state) }} |
|
|
|
|
|
{%- endif %} |
|
|
{%- endif -%} |
|
|
{%- endif -%} |
|
|
{%- endif -%} |
|
|
{%- endif -%} |
|
|
{%- endmacro %} |
|
|
{%- endmacro %} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Managed enabled/disabled state for servers |
|
|
# Managed enabled/disabled state for servers |
|
|
{% for server, settings in nginx.servers.managed.items() %} |
|
|
{% for server, settings in nginx.servers.managed.items() %} |
|
|
{% if settings.config != None %} |
|
|
|
|
|
|
|
|
{% set conf_state_id = 'server_conf_' ~ loop.index0 %} |
|
|
|
|
|
{% if 'deleted' in settings and settings.deleted %} |
|
|
|
|
|
{{ conf_state_id }}: |
|
|
|
|
|
file.absent: |
|
|
|
|
|
- name: {{ server_curpath(server) }} |
|
|
|
|
|
{% else %} |
|
|
|
|
|
{% if settings.config != None and settings.enabled == True %} |
|
|
{% if 'source_path' in settings.config %} |
|
|
{% if 'source_path' in settings.config %} |
|
|
{% set source_path = settings.config.source_path %} |
|
|
{% set source_path = settings.config.source_path %} |
|
|
{% else %} |
|
|
{% else %} |
|
|
{% set source_path = 'salt://nginx/ng/files/server.conf' %} |
|
|
{% set source_path = 'salt://nginx/ng/files/server.conf' %} |
|
|
{% endif %} |
|
|
{% endif %} |
|
|
{% set conf_state_id = 'server_conf_' ~ loop.index0 %} |
|
|
|
|
|
{{ conf_state_id }}: |
|
|
{{ conf_state_id }}: |
|
|
file.managed: |
|
|
file.managed: |
|
|
{{ sls_block(nginx.servers.managed_opts) }} |
|
|
{{ sls_block(nginx.servers.managed_opts) }} |
|
|
|
|
|
|
|
|
{% endif %} |
|
|
{% endif %} |
|
|
{% do server_states.append(conf_state_id) %} |
|
|
{% do server_states.append(conf_state_id) %} |
|
|
{% endif %} |
|
|
{% 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 %} |
|
|
{{ status_state_id }}: |
|
|
{{ status_state_id }}: |
|
|
{{ manage_status(server, settings.enabled) }} |
|
|
|
|
|
{% if settings.config != None %} |
|
|
|
|
|
|
|
|
{% if 'deleted' in settings and settings.deleted %} |
|
|
|
|
|
{{ manage_status(server, False, True) }} |
|
|
|
|
|
{% else %} |
|
|
|
|
|
{{ manage_status(server, settings.enabled, False) }} |
|
|
|
|
|
{% endif %} |
|
|
|
|
|
{% if settings.config != None and settings.enabled == True %} |
|
|
- require: |
|
|
- require: |
|
|
- 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 %} |
|
|
|
|
|
{% endif %} |
|
|
{% endfor %} |
|
|
{% endfor %} |