Skip to content

Commit cbe3bdb

Browse files
author
Christopher M. Neill
committed
Merge branch 'master' into SAN-3496-json-logs
2 parents 899fed2 + 162f466 commit cbe3bdb

13 files changed

Lines changed: 115 additions & 199 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ ca.srl
1010
.DS_Store
1111
ansible/roles/hipache/templates/runnable*
1212
ansible/certs/*
13+
*.retry
14+

ansible/eru.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
- hosts: consul
33
- hosts: mongodb
44
- hosts: redis
5+
- hosts: socket-server-proxy
56

67
- hosts: eru
78
vars_files:
@@ -10,9 +11,7 @@
1011
- { role: notify, tags: [ notify ] }
1112
- { role: builder, tags: [ build ] }
1213
- role: container_start
13-
14-
- hosts: socket-server-proxy
15-
vars_files:
16-
- group_vars/alpha-eru.yml
17-
roles:
18-
- role: eru
14+
- role: nginx-proxied-service
15+
nginx_host: "{{ groups['socket-server-proxy'][0] }}"
16+
target_ip_address: "{{ hostvars[groups['eru'][0]]['ansible_default_ipv4']['address'] }}"
17+
templates: [ 11-eru-server.conf ]

ansible/group_vars/alpha-eru.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ container_tag: "{{ git_branch }}"
66
repo: git@github.com:CodeNow/{{ name }}.git
77
hosted_ports: [ "5501", "5502" ]
88
node_version: lts
9-
npm_version: 2
9+
npm_version: 3
1010
has_shrinkwrap: true
1111

1212
dockerfile_post_install_commands:

ansible/roles/eru/tasks/main.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

ansible/roles/khronos/tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
with_items:
2222
- name: Khronos CLI - Daily Cleanup
2323
minute: 13
24-
hour: 1,7,13,19
24+
hour: 1,4,7,10,13,16,19,22
2525
script: main-cron.sh
2626
- name: Khronos CLI - Canary
2727
minute: "*/5"
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
# these are pretty hacky, but it should work
3+
# Get port information from the hosted service
4+
- name: get eru ports
5+
when: name == "eru"
6+
tags: [ configure_proxy, deploy ]
7+
become: true
8+
shell: |
9+
for c in $(docker ps | awk '/eru/{ print $1 }'); do
10+
docker port $c 5501 | cut -d ':' -f 2
11+
docker port $c 5502 | cut -d ':' -f 2
12+
done
13+
args:
14+
executable: /bin/bash
15+
register: eru_target_ports
16+
17+
- name: get socket server ports
18+
when: name == "api-socket-server"
19+
tags: [ configure_proxy, deploy ]
20+
become: true
21+
shell: |
22+
for c in $(docker ps | awk '/api-socket-server/{ print $1 }'); do
23+
docker port $c 80 | cut -d ':' -f 2
24+
done
25+
args:
26+
executable: /bin/bash
27+
register: socket_target_ports
28+
29+
# everything from this point on is deligated to the nginx host
30+
31+
- name: print target ports
32+
delegate_to: "{{ nginx_host }}"
33+
tags: [ configure_proxy, deploy ]
34+
debug:
35+
msg: |
36+
eru ports -- {{ eru_target_ports }}
37+
socket ports -- {{ socket_target_ports }}
38+
39+
- name: print target IP address
40+
delegate_to: "{{ nginx_host }}"
41+
tags: [ configure_proxy, deploy ]
42+
debug:
43+
msg: ip -- {{ target_ip_address }}
44+
45+
- name: assert nginx config directory
46+
delegate_to: "{{ nginx_host }}"
47+
tags: [ configure_proxy, deploy ]
48+
become: yes
49+
file:
50+
state: directory
51+
dest: /etc/nginx
52+
53+
- name: assert nginx sites-available directory
54+
delegate_to: "{{ nginx_host }}"
55+
tags: [ configure_proxy, deploy ]
56+
become: yes
57+
file:
58+
state: directory
59+
dest: /etc/nginx/sites-available
60+
61+
- name: assert nginx sites-enable directory
62+
delegate_to: "{{ nginx_host }}"
63+
tags: [ configure_proxy, deploy ]
64+
become: yes
65+
file:
66+
state: directory
67+
dest: /etc/nginx/sites-enable
68+
69+
- name: put configuration in place
70+
delegate_to: "{{ nginx_host }}"
71+
tags: [ configure_proxy, deploy ]
72+
become: yes
73+
template:
74+
src: "{{ item }}"
75+
dest: /etc/nginx/sites-available/{{ item }}
76+
with_items: "{{ templates }}"
77+
78+
- name: link configuration to enable
79+
delegate_to: "{{ nginx_host }}"
80+
tags: [ configure_proxy, deploy ]
81+
become: yes
82+
file:
83+
state: link
84+
dest: /etc/nginx/sites-enabled/{{ item }}
85+
src: /etc/nginx/sites-available/{{ item }}
86+
with_items: "{{ templates }}"
87+
88+
- name: reload nginx
89+
delegate_to: "{{ nginx_host }}"
90+
tags: [ configure_proxy, deploy ]
91+
become: yes
92+
shell: >
93+
docker ps |
94+
awk '/nginx/{ print $1 }' |
95+
xargs -n 1 docker kill --signal SIGHUP
96+
args:
97+
executable: /bin/bash

ansible/roles/socket-proxy/templates/00-nginx-status.conf renamed to ansible/roles/nginx-proxied-service/templates/00-nginx-status.conf

File renamed without changes.

ansible/roles/socket-proxy/templates/01-socket-server.conf renamed to ansible/roles/nginx-proxied-service/templates/01-socket-server.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ map $http_upgrade $connection_upgrade {
55

66
upstream socketserver {
77
sticky;
8-
{% for port in ports.stdout_lines -%}
9-
server {{ socket_server_hostname }}:{{ port }};
8+
{% for port in socket_target_ports.stdout_lines -%}
9+
server {{ target_ip_address }}:{{ port }};
1010
{% endfor %}
1111
}
1212

ansible/roles/eru/templates/11-eru-server.conf renamed to ansible/roles/nginx-proxied-service/templates/11-eru-server.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ server {
3535

3636
location / {
3737
expires 300;
38-
proxy_pass http://{{ eru_server_hostname }}:{{ ports.stdout_lines[0] | trim }};
38+
proxy_pass http://{{ target_ip_address }}:{{ eru_target_ports.stdout_lines[0] | trim }};
3939
proxy_set_header Host $host;
4040
proxy_set_header x-real-ip $remote_addr;
4141
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
@@ -44,7 +44,7 @@ server {
4444
}
4545

4646
location /graphql {
47-
proxy_pass http://{{ eru_server_hostname }}:{{ ports.stdout_lines[1] | trim }};
47+
proxy_pass http://{{ target_ip_address }}:{{ eru_target_ports.stdout_lines[1] | trim }};
4848
proxy_set_header Host $host;
4949
proxy_set_header x-real-ip $remote_addr;
5050
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;

ansible/roles/socket-proxy/files/nginx.conf

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)