Skip to content

Commit 59d074d

Browse files
author
Anandkumar Patel
committed
add uptables to ansible for navi, cleanup
1 parent f41c29f commit 59d074d

5 files changed

Lines changed: 25 additions & 12 deletions

File tree

ansible/group_vars/alpha-consul-template-updater.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ container_run_opts: >
1414
container_run_args: >
1515
-consul={{ consul_host_address }}:{{ consul_api_port }}
1616
-wait=1s
17-
-template="/tmp/template:{{ target_updater_file_path }}/{{ out_file }}:{{ template_command }}"
17+
-template="/tmp/template:{{ target_updater_file_path }}/{{ proxy_service_name }}.conf:{{ template_command }}"

ansible/group_vars/alpha-navi-proxy.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22
name: nginx
33

44
# used by consul template updater
5+
proxy_service_name: navi
56
target_container_name: nginx
67
target_updater_file_path: /etc/nginx/sites-enabled
7-
template_path: /etc/nginx/template/navi.tmpl
88
template_command: /bin/docker kill -s HUP {{ target_container_name }}
9-
out_file: navi.conf
9+
template_path: /etc/nginx/template/navi.tmpl
1010

1111
# used by container_kill_start
1212
container_image: "{{ name }}"
1313
container_tag: "1.10"
1414

15+
restart_policy: always
16+
1517
container_run_opts: >
1618
-d
1719
--net=host

ansible/group_vars/alpha-registrator.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ name: registrator
44
container_image: gliderlabs/registrator
55
container_tag: v7
66

7+
restart_policy: always
8+
79
container_run_opts: >
810
-d
911
--hostname={{ ansible_hostname }}

ansible/roles/content-domain-proxy/tasks/main.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,6 @@
4444
dest: /etc/nginx
4545
state: directory
4646

47-
- name: assert nginx sites-enabled directory
48-
tags: [ configure_proxy ]
49-
become: yes
50-
file:
51-
state: directory
52-
dest: /etc/nginx/sites-enabled
53-
5447
- name: put nginx configuration in place
5548
tags: [ configure_proxy ]
5649
become: yes
@@ -70,4 +63,20 @@
7063
become: yes
7164
template:
7265
src: navi.tmpl
73-
dest: /etc/nginx/template
66+
dest: /etc/nginx/template/navi.tmpl
67+
68+
- name: setup ip table rule to redir all to port 80
69+
tags: [ configure_proxy, iptables ]
70+
become: yes
71+
iptables:
72+
table=nat
73+
chain=PREROUTING
74+
in_interface=eth0
75+
protocol=tcp
76+
destination_port={{ item }}
77+
jump=REDIRECT
78+
to_ports=80
79+
comment="Redirect {{ item }} traffic to port 80"
80+
with_items:
81+
- 81:442
82+
- 444:65535

ansible/roles/content-domain-proxy/templates/navi.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ map $http_upgrade $connection_upgrade {
44
}
55

66
upstream {{ name }} {
7-
{{ '{{' }}range service "{{ name }}"{{ '}}' }} server {{ '{{' }}.Address{{ '}}' }}:{{ '{{' }}.Port{{ '}}' }} max_fails=0 fail_timeout=1s;
7+
{{ '{{' }}range service "{{ proxy_service_name }}"{{ '}}' }} server {{ '{{' }}.Address{{ '}}' }}:{{ '{{' }}.Port{{ '}}' }} max_fails=0 fail_timeout=1s;
88
{{ '{{' }}end{{ '}}' }}
99
}
1010

0 commit comments

Comments
 (0)