Переглянути джерело

feat(servers_config): enable configs by default

Don't require `enabled: true` - helps distributions without
separate available/enabled directories and prevents error:
"Rendering SLS 'production:nginx.servers' failed: Jinja variable 'list
object' has no attribute 'enabled'"

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
pull/300/head
Georg Pfuetzenreuter 1 рік тому
джерело
коміт
23df36ded9
Аккаунт користувача з таким Email не знайдено
2 змінених файлів з 7 додано та 5 видалено
  1. +5
    -4
      nginx/servers_config.sls
  2. +2
    -1
      pillar.example

+ 5
- 4
nginx/servers_config.sls Переглянути файл



# 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() %}
{% set server_enabled = settings.enabled | default(True) %}
{% set conf_state_id = 'server_conf_' ~ loop.index0 %} {% set conf_state_id = 'server_conf_' ~ loop.index0 %}
{% if 'deleted' in settings and settings.deleted %} {% if 'deleted' in settings and settings.deleted %}
{{ conf_state_id }}: {{ conf_state_id }}:
- name: {{ server_curpath(server) }} - name: {{ server_curpath(server) }}
{% do server_states.append(conf_state_id) %} {% do server_states.append(conf_state_id) %}
{% else %} {% else %}
{% if settings.enabled == True %}
{% if server_enabled == True %}
{{ conf_state_id }}: {{ conf_state_id }}:
file.managed: file.managed:
{{ sls_block(nginx.servers.managed_opts) }} {{ sls_block(nginx.servers.managed_opts) }}
{% endif %} {% endif %}
{% endif %} {% endif %}


{% if settings.enabled != None %}
{% if settings.enabled is defined and server_enabled != None %}
{% set status_state_id = 'server_state_' ~ loop.index0 %} {% set status_state_id = 'server_state_' ~ loop.index0 %}
{%- set enabled_dir = path_join(server, nginx.servers.managed.get(server).get('enabled_dir', nginx.lookup.server_enabled)) -%} {%- set enabled_dir = path_join(server, nginx.servers.managed.get(server).get('enabled_dir', nginx.lookup.server_enabled)) -%}
{%- set available_dir = path_join(server, nginx.servers.managed.get(server).get('available_dir', nginx.lookup.server_available)) -%} {%- set available_dir = path_join(server, nginx.servers.managed.get(server).get('available_dir', nginx.lookup.server_available)) -%}
{% if 'deleted' in settings and settings.deleted %} {% if 'deleted' in settings and settings.deleted %}
{{ manage_status(server, False, True) }} {{ manage_status(server, False, True) }}
{% else %} {% else %}
{{ manage_status(server, settings.enabled, False) }}
{{ manage_status(server, server_enabled, False) }}
{% endif %} {% endif %}
{% if settings.enabled == True %}
{% if server_enabled == True %}
- require: - require:
- file: {{ conf_state_id }} - file: {{ conf_state_id }}
{% endif %} {% endif %}

+ 2
- 1
pillar.example Переглянути файл

# relative filename of server file # relative filename of server file
# (defaults to '/etc/nginx/sites-available/mysite') # (defaults to '/etc/nginx/sites-available/mysite')
mysite: mysite:
# may be true, false, or None where true is enabled, false, disabled,
# may be true, false, or None where true is enabled, false is disabled,
# and None indicates no action # and None indicates no action
# true without ".disabled" management if not specified
enabled: true enabled: true


# This let's you add dependencies on other resources being applied for a # This let's you add dependencies on other resources being applied for a

Завантаження…
Відмінити
Зберегти