File tree 10 files changed +65
-6
lines changed
integration/default/controls 10 files changed +65
-6
lines changed Original file line number Diff line number Diff line change @@ -373,9 +373,13 @@ verifier:
373
373
suites :
374
374
- name : default
375
375
provisioner :
376
+ dependencies :
377
+ - name : test_dep
378
+ path : test/salt/default/states
376
379
state_top :
377
380
base :
378
381
' * ' :
382
+ - test_dep.create_dependency_file
379
383
- nginx._mapdata
380
384
- nginx
381
385
pillars :
Original file line number Diff line number Diff line change @@ -31,6 +31,3 @@ nginx_config:
31
31
- context:
32
32
config: {{ nginx.server.config| json(sort_keys = False ) }}
33
33
{% endif % }
34
- {% if nginx.check_config_before_apply % }
35
- - check_cmd: / usr/ sbin/ nginx - t - c
36
- {% endif % }
Original file line number Diff line number Diff line change @@ -123,6 +123,12 @@ nginx_server_available_dir:
123
123
}}
124
124
- makedirs: True
125
125
- template: jinja
126
+ {%- if ' requires' in settings % }
127
+ - require:
128
+ {%- for k, v in settings.requires.items() % }
129
+ - {{ k }}: {{ v }}
130
+ {%- endfor % }
131
+ {%- endif % }
126
132
{% if ' source_path' not in settings.config % }
127
133
- context:
128
134
config: {{ settings.config| json(sort_keys = False ) }}
Original file line number Diff line number Diff line change @@ -42,3 +42,6 @@ nginx_service:
42
42
{% else % }
43
43
- pkg: nginx_install
44
44
{% endif % }
45
+ {% if nginx.check_config_before_apply % }
46
+ - only_if: / usr/ sbin/ nginx - t
47
+ {% endif % }
Original file line number Diff line number Diff line change @@ -202,6 +202,18 @@ nginx:
202
202
# and None indicates no action
203
203
enabled : true
204
204
205
+ # This let's you add dependencies on other resources being applied for a
206
+ # particular vhost
207
+ # A common case is when you use this formula together with letsencrypt's,
208
+ # validating through nginx: you need nginx running (to validate the vhost) but
209
+ # can't have the ssl vhost up until the certificate is created (because it
210
+ # won't exist and will make nginx fail to load the configuration)
211
+ #
212
+ # An example, when using LE to create the cert for 'some.host.domain':
213
+ # requires:
214
+ # cmd: create-initial-cert-some.host.domain
215
+ requires : {}
216
+
205
217
# Remove the site config file shipped by nginx
206
218
# (i.e. '/etc/nginx/sites-available/default' by default)
207
219
# It also remove the symlink (if it is exists).
Original file line number Diff line number Diff line change 71
71
its ( 'content' ) { should include 'try_files $uri $uri/ =404;' }
72
72
its ( 'content' ) { should include 'include snippets/letsencrypt.conf;' }
73
73
end
74
+ describe file "#{ dir } /mysite_with_require" do
75
+ it { should be_file }
76
+ it { should be_owned_by file_owner }
77
+ it { should be_grouped_into file_group }
78
+ its ( 'mode' ) { should cmp '0644' }
79
+ its ( 'content' ) { should include 'server_name with-deps;' }
80
+ its ( 'content' ) { should include 'listen 80;' }
81
+ its ( 'content' ) { should include 'index index.html index.htm;' }
82
+ its ( 'content' ) { should include 'location ~ .htm {' }
83
+ its ( 'content' ) { should include 'try_files $uri $uri/ =404;' }
84
+ end
74
85
end
75
86
end
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ control 'Dependency test file' do
4
+ title 'should exist'
5
+
6
+ describe file ( '/tmp/created_to_test_dependencies' ) do
7
+ it { should be_file }
8
+ end
9
+ end
Original file line number Diff line number Diff line change @@ -37,6 +37,19 @@ nginx:
37
37
- location ~ .htm :
38
38
- try_files : ' $uri $uri/ =404'
39
39
- include : ' snippets/letsencrypt.conf'
40
+ mysite_with_require :
41
+ enabled : true
42
+ config :
43
+ - server :
44
+ - server_name : with-deps
45
+ - listen :
46
+ - ' 80'
47
+ - index : ' index.html index.htm'
48
+ - location ~ .htm :
49
+ - try_files : ' $uri $uri/ =404'
50
+ requires :
51
+ file : created_to_test_dependencies
52
+
40
53
dh_param :
41
54
' mydhparam2.pem ' :
42
55
keysize : 2048
Original file line number Diff line number Diff line change
1
+ # # this state creates a file that is used to test vhosts dependencies
2
+ # (see https://github.com/saltstack-formulas/nginx-formula/pull/278)
3
+
4
+ created_to_test_dependencies:
5
+ file.managed :
6
+ - name: /tmp/created_to_test_dependencies
Original file line number Diff line number Diff line change 26
26
- location ^~ /.well-known/acme-challenge/ :
27
27
- proxy_pass : http://localhost:9999
28
28
server :
29
-
30
29
config :
31
30
# This is required to get the passenger module loaded
32
31
# In Debian it can be done with this
64
63
- index : ' index.html index.htm'
65
64
- location ~ .htm :
66
65
- try_files : ' $uri $uri/ =404'
67
- # - include: '/etc/nginx/snippets/letsencrypt.conf'
68
- - include : ' snippets/letsencrypt.conf'
66
+ - include : ' /etc/nginx/snippets/letsencrypt.conf'
You can’t perform that action at this time.
0 commit comments