feat(servers_config): add require statement to manage dependencies
Also, check config before applying
This commit is contained in:
		
							parent
							
								
									b9e9cd38e6
								
							
						
					
					
						commit
						622d22f971
					
				@ -31,6 +31,3 @@ nginx_config:
 | 
			
		||||
    - context:
 | 
			
		||||
        config: {{ nginx.server.config|json(sort_keys=False) }}
 | 
			
		||||
{% endif %}
 | 
			
		||||
{% if nginx.check_config_before_apply %}
 | 
			
		||||
    - check_cmd: /usr/sbin/nginx -t -c
 | 
			
		||||
{% endif %}
 | 
			
		||||
 | 
			
		||||
@ -123,6 +123,12 @@ nginx_server_available_dir:
 | 
			
		||||
      }}
 | 
			
		||||
    - makedirs: True
 | 
			
		||||
    - 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 %}
 | 
			
		||||
    - context:
 | 
			
		||||
        config: {{ settings.config|json(sort_keys=False) }}
 | 
			
		||||
 | 
			
		||||
@ -42,3 +42,6 @@ nginx_service:
 | 
			
		||||
      {% else %}
 | 
			
		||||
      - pkg: nginx_install
 | 
			
		||||
      {% endif %}
 | 
			
		||||
{% if nginx.check_config_before_apply %}
 | 
			
		||||
    - only_if: /usr/sbin/nginx -t
 | 
			
		||||
{% endif %}
 | 
			
		||||
 | 
			
		||||
@ -202,6 +202,18 @@ nginx:
 | 
			
		||||
        # and None indicates no action
 | 
			
		||||
        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
 | 
			
		||||
        # (i.e. '/etc/nginx/sites-available/default' by default)
 | 
			
		||||
        # It also remove the symlink (if it is exists).
 | 
			
		||||
 | 
			
		||||
@ -26,7 +26,6 @@ nginx:
 | 
			
		||||
      - location ^~ /.well-known/acme-challenge/:
 | 
			
		||||
          - proxy_pass: http://localhost:9999
 | 
			
		||||
  server:
 | 
			
		||||
 | 
			
		||||
    config:
 | 
			
		||||
      # This is required to get the passenger module loaded
 | 
			
		||||
      # In Debian it can be done with this
 | 
			
		||||
@ -64,5 +63,4 @@ nginx:
 | 
			
		||||
              - index: 'index.html index.htm'
 | 
			
		||||
              - location ~ .htm:
 | 
			
		||||
                  - try_files: '$uri $uri/ =404'
 | 
			
		||||
              # - include: '/etc/nginx/snippets/letsencrypt.conf'
 | 
			
		||||
              - include: 'snippets/letsencrypt.conf'
 | 
			
		||||
              - include: '/etc/nginx/snippets/letsencrypt.conf'
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user