forked from AutomationWithAnsible/ansible-nginx
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generalized fragment templates to location templates. (#5)
* Generalized fragment templates to location templates. * Skip task if variable is not defined. * Fixed template overwriting common_config
- Loading branch information
Showing
8 changed files
with
127 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
##{{ ansible_managed }} | ||
{% for config_block in item['list'] %} | ||
location {{ config_block.path }} { | ||
{% if 'proxy_pass' in config_block %} | ||
proxy_pass http://{{ config_block.proxy_pass }}; | ||
{% endif %} | ||
|
||
{% if 'common_config' in item %} | ||
{% set combined_config = dict(item['common_config']) %} | ||
{% set _ = combined_config.update(config_block) %} | ||
{% else %} | ||
{% set combined_config = config_block %} | ||
{% endif %} | ||
{% for key, value in combined_config.iteritems() %} | ||
{% if key not in ['proxy_pass', 'path', 'server'] %} | ||
{% if value is iterable and value is not string %} | ||
{% for array_value in value %} | ||
{{ key }} {{ array_value }}; | ||
{% endfor %} | ||
{% else %} | ||
{{ key }} {{ value }}; | ||
{% endif %} | ||
{% endif %} | ||
{% endfor %} | ||
} | ||
|
||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
##{{ ansible_managed }} | ||
{% if 'create_upstreams' in item and item['create_upstreams'] == 'false' %} | ||
{% else %} | ||
{% set data = {} %} | ||
{% for config_block in item['list'] %} | ||
{% if 'proxy_pass' in config_block and not config_block.proxy_pass in data %} | ||
{% set _ = data.update({config_block.proxy_pass: "1"}) %} | ||
upstream {{ config_block.proxy_pass }} { | ||
{% if 'proxy_pass' in config_block %} | ||
{% if config_block.proxy_pass in consul_services%} | ||
{% if 'local_port' in consul_services[config_block.proxy_pass] %} | ||
server 127.0.0.1:{{ consul_services[config_block.proxy_pass]['local_port'] }}; | ||
{% else %} | ||
server 127.0.0.1:{{ consul_services[config_block.proxy_pass]['port'] }}; | ||
{% endif %} | ||
{% else %} | ||
server {{ config_block.proxy_pass }}; | ||
{% endif %} | ||
{% endif %} | ||
} | ||
{% endif %} | ||
{% endfor %} | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters