Browse Source

feat(servers_config): add require statement to manage dependencies

Also, check config before applying
tags/v2.7.0
Javier Bértoli 3 years ago
parent
commit
622d22f971
5 changed files with 22 additions and 6 deletions
  1. +0
    -3
      nginx/config.sls
  2. +6
    -0
      nginx/servers_config.sls
  3. +3
    -0
      nginx/service.sls
  4. +12
    -0
      pillar.example
  5. +1
    -3
      test/salt/passenger/pillar/nginx.sls

+ 0
- 3
nginx/config.sls View File

- context: - context:
config: {{ nginx.server.config|json(sort_keys=False) }} config: {{ nginx.server.config|json(sort_keys=False) }}
{% endif %} {% endif %}
{% if nginx.check_config_before_apply %}
- check_cmd: /usr/sbin/nginx -t -c
{% endif %}

+ 6
- 0
nginx/servers_config.sls View File

}} }}
- makedirs: True - makedirs: True
- template: jinja - template: jinja
{%- if 'requires' in settings %}
- require:
{%- for k, v in settings.requires.items() %}
- {{ k }}: {{ v }}
{%- endfor %}
{%- endif %}
{% 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) }}

+ 3
- 0
nginx/service.sls View File

{% else %} {% else %}
- pkg: nginx_install - pkg: nginx_install
{% endif %} {% endif %}
{% if nginx.check_config_before_apply %}
- only_if: /usr/sbin/nginx -t
{% endif %}

+ 12
- 0
pillar.example View File

# and None indicates no action # and None indicates no action
enabled: true enabled: true


# This let's you add dependencies on other resources being applied for a
# particular vhost
# A common case is when you use this formula together with letsencrypt's,
# validating through nginx: you need nginx running (to validate the vhost) but
# can't have the ssl vhost up until the certificate is created (because it
# won't exist and will make nginx fail to load the configuration)
#
# An example, when using LE to create the cert for 'some.host.domain':
# requires:
# cmd: create-initial-cert-some.host.domain
requires: {}

# Remove the site config file shipped by nginx # Remove the site config file shipped by nginx
# (i.e. '/etc/nginx/sites-available/default' by default) # (i.e. '/etc/nginx/sites-available/default' by default)
# It also remove the symlink (if it is exists). # It also remove the symlink (if it is exists).

+ 1
- 3
test/salt/passenger/pillar/nginx.sls View File

- location ^~ /.well-known/acme-challenge/: - location ^~ /.well-known/acme-challenge/:
- proxy_pass: http://localhost:9999 - proxy_pass: http://localhost:9999
server: server:

config: config:
# This is required to get the passenger module loaded # This is required to get the passenger module loaded
# In Debian it can be done with this # In Debian it can be done with this
- index: 'index.html index.htm' - index: 'index.html index.htm'
- location ~ .htm: - location ~ .htm:
- try_files: '$uri $uri/ =404' - try_files: '$uri $uri/ =404'
# - include: '/etc/nginx/snippets/letsencrypt.conf'
- include: 'snippets/letsencrypt.conf'
- include: '/etc/nginx/snippets/letsencrypt.conf'

Loading…
Cancel
Save