File tree Expand file tree Collapse file tree 2 files changed +32
-11
lines changed Expand file tree Collapse file tree 2 files changed +32
-11
lines changed Original file line number Diff line number Diff line change @@ -19,12 +19,30 @@ nginx_sites:
19
19
listen : 8080
20
20
server_name : localhost
21
21
root : " /tmp/site1"
22
- location1 : {name: /, try_files: "$uri $uri/ /index.html"}
23
- location2 : {name: /images/, try_files: "$uri $uri/ /index.html"}
22
+ locations :
23
+ - name : /
24
+ try_files :
25
+ - $uri
26
+ - $uri/
27
+ - /index.html
28
+ - name : /images/
29
+ try_files :
30
+ - $uri
31
+ - $uri/
32
+ - /index.html
24
33
- server :
25
34
file_name : bar
26
35
listen : 9090
27
36
server_name : ansible
28
37
root : " /tmp/site2"
29
- location1 : {name: /, try_files: "$uri $uri/ /index.html"}
30
- location2 : {name: /images/, try_files: "$uri $uri/ /index.html"}
38
+ locations :
39
+ - name : /
40
+ try_files :
41
+ - $uri
42
+ - $uri/
43
+ - /index.html
44
+ - name : /images/
45
+ try_files :
46
+ - $uri
47
+ - $uri/
48
+ - /index.html
Original file line number Diff line number Diff line change @@ -6,17 +6,20 @@ server {
6
6
{% endif %}
7
7
8
8
{% for k ,v in item .server .iteritems () %}
9
- {% if k . find ( 'location' ) == -1 and k != 'file_name' %}
9
+ {% if k != 'locations' and k != 'file_name' %}
10
10
{{ k }} {{ v }};
11
11
{% endif %}
12
- {% endfor %}
12
+ {% endfor %}
13
13
14
- {% for k ,v in item .server .iteritems () if k .find ('location' ) != -1 %}
15
- location {{ v.name }} {
16
- {% for x ,y in v .iteritems () if x != 'name' %}
17
- {{ x }} {{ y }};
14
+ {% for loc in item .server .locations %}
15
+ location {{ loc.name }} {
16
+ {% for x ,y in loc .iteritems () if x != 'name' %}
17
+ {% if x == 'try_files' %}
18
+ {{ x }} {{ y | join(' ')}};
19
+ {% else %}
20
+ {{ x }} {{ y }};
21
+ {% endif %}
18
22
{% endfor %}
19
23
}
20
24
{% endfor %}
21
25
}
22
-
You can’t perform that action at this time.
0 commit comments