Skip to content

Instantly share code, notes, and snippets.

@nomasprime
Last active May 20, 2016 17:42
Show Gist options
  • Save nomasprime/8460d54406d01d90e7ab215259283a66 to your computer and use it in GitHub Desktop.
Save nomasprime/8460d54406d01d90e7ab215259283a66 to your computer and use it in GitHub Desktop.
---
common_packages_install:
- avahi-daemon
nginx_site_configs:
app:
servers:
- listen: 80
locations:
- access_log: "{{ nginx_log_dir }}/app/access.log upstream"
proxy_pass: "http://app"
# proxy_set_headers:
# X-MOCK-UPSTREAM-HOST: $upstream_addr
uri: "/"
upstreams:
app:
servers:
- "{{ hostvars['ansible-demo-app0']['ansible_eth1']['ipv4']['address'] }}:8484"
- "{{ hostvars['ansible-demo-app1']['ansible_eth1']['ipv4']['address'] }}:8484"
secure_iptables_accept_avahi: true
secure_iptables_accept_http: true
# {{ ansible_managed }}
{% for upstream_key, upstream_value in item.value.upstreams.iteritems() %}
upstream {{ upstream_key }} {
{% for server in upstream_value.servers %}
server {{ server }};
{% endfor %}
}
{% endfor %}
{% for server in item.value.servers %}
server {
listen {{ server.listen }};
{% for location in server.locations %}
location {{ location.uri }} {
{% if location.access_log | default() %}
access_log {{ location.access_log }};
{% endif %}
{% if location.proxy_pass | default() %}
proxy_pass {{ location.proxy_pass }};
{% endif %}
{% if location.proxy_set_headers is defined %}
{% for proxy_set_header_key, proxy_set_header_value in location.proxy_set_headers.iteritems() -%}
proxy_set_header {{ proxy_set_header_key }} {{ proxy_set_header_value }};
{% endfor %}
{% endif %}
}
{% endfor %}
}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment