Skip to content

Commit 3edde60

Browse files
author
Anandkumar Patel
committed
move nginx folder logic into proxy
consolidate cert path
1 parent cc3a884 commit 3edde60

8 files changed

Lines changed: 65 additions & 94 deletions

File tree

ansible/group_vars/alpha-navi-proxy.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ container_run_opts: >
1010
-p 0.0.0.0:443:443
1111
-p 0.0.0.0:80:80
1212
-v /etc/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
13-
-v /etc/nginx/sites-available/:/etc/nginx/sites-enabled/:ro
14-
-v /etc/nginx/ssl/dhparam.pem:/etc/nginx/ssl/dhparam.pem:ro
13+
-v /etc/nginx/sites-enabled/:/etc/nginx/sites-enabled/:ro
1514
-v /etc/ssl/certs/{{ user_content_domain }}:/etc/ssl/certs/{{ user_content_domain }}:ro
1615
-v /var/log/nginx:/var/log/nginx

ansible/navi-proxy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
- role: datadog
77
has_dd_integration: yes
88

9-
- role: content-domain-certs
9+
- role: content-domain-proxy
1010

1111
- role: container_kill_start

ansible/navi.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
- hosts: mongo-navi
55
- hosts: rabbitmq
66
- hosts: consul
7-
- hosts: userland
87

98
- hosts: navi
109
vars_files:

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

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
- name: make sure cert directory is in place
3+
tags: [ configure_proxy, certs ]
4+
become: true
5+
file:
6+
dest: /etc/ssl/certs/{{ user_content_domain }}
7+
state: directory
8+
9+
- name: put certs in place
10+
tags: [ configure_proxy, certs ]
11+
become: true
12+
register: add_certs
13+
copy:
14+
src: "{{ user_content_domain }}/{{ item }}"
15+
dest: /etc/ssl/certs/{{ user_content_domain }}/{{ item }}
16+
mode: 0400
17+
owner: root
18+
group: root
19+
with_items:
20+
- ca.pem
21+
- key.pem
22+
- cert.pem
23+
24+
- name: create chained cert
25+
tags: [ configure_proxy, certs ]
26+
become: true
27+
when: add_certs.changed
28+
shell: >
29+
cat
30+
/etc/ssl/certs/{{ user_content_domain }}/cert.pem
31+
/etc/ssl/certs/{{ user_content_domain }}/ca.pem
32+
>
33+
/etc/ssl/certs/{{ user_content_domain }}/chained.pem
34+
35+
- name: create dhparam.pem
36+
tags: [ configure_proxy, certs ]
37+
become: yes
38+
command: openssl dhparam -out /etc/ssl/certs/{{ user_content_domain }}/dhparam.pem 2048
39+
40+
- name: make sure nginx directory is in place
41+
tags: [ configure_proxy ]
42+
become: true
43+
file:
44+
dest: /etc/nginx
45+
state: directory
46+
47+
48+
- name: assert nginx sites-enabled directory
49+
tags: [ configure_proxy ]
50+
become: yes
51+
file:
52+
state: directory
53+
dest: /etc/nginx/sites-enabled
54+
55+
- name: put nginx configuration in place
56+
tags: [ configure_proxy ]
57+
become: yes
58+
template:
59+
src: proxy-nginx.conf
60+
dest: /etc/nginx/nginx.conf

ansible/roles/nginx-proxied-service/templates/proxy-nginx.conf renamed to ansible/roles/content-domain-proxy/templates/proxy-nginx.conf

File renamed without changes.

ansible/roles/nginx-proxied-service/tasks/main.yml

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -15,75 +15,21 @@
1515
register: proxy_target_ports
1616

1717
# everything from this point on is delegated to the nginx host
18-
- name: put dhparam in place
19-
delegate_to: "{{ nginx_host }}"
20-
tags: [ configure_proxy ]
21-
become: yes
22-
command: openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
23-
24-
- name: print target ports
18+
- name: print target info
2519
delegate_to: "{{ nginx_host }}"
2620
tags: [ configure_proxy, deploy ]
2721
debug:
2822
msg: |
2923
proxy target ports -- {{ proxy_target_ports }}
30-
31-
- name: print target IP address
32-
delegate_to: "{{ nginx_host }}"
33-
tags: [ configure_proxy, deploy ]
34-
debug:
35-
msg: ip -- {{ target_ip_address }}
36-
37-
- name: assert nginx config directory
38-
delegate_to: "{{ nginx_host }}"
39-
tags: [ configure_proxy, deploy ]
40-
become: yes
41-
file:
42-
state: directory
43-
dest: /etc/nginx
44-
45-
- name: assert nginx sites-available directory
46-
delegate_to: "{{ nginx_host }}"
47-
tags: [ configure_proxy, deploy ]
48-
become: yes
49-
file:
50-
state: directory
51-
dest: /etc/nginx/sites-available
52-
53-
- name: assert nginx sites-enable directory
54-
delegate_to: "{{ nginx_host }}"
55-
tags: [ configure_proxy, deploy ]
56-
become: yes
57-
file:
58-
state: directory
59-
dest: /etc/nginx/sites-enable
60-
61-
- name: put nginx configuration in place
62-
when: nginx_config is defined and nginx_config == "proxy"
63-
delegate_to: "{{ nginx_host }}"
64-
tags: [ configure_proxy, deploy ]
65-
become: yes
66-
template:
67-
src: "{{ nginx_config }}-nginx.conf"
68-
dest: /etc/nginx/nginx.conf
24+
ip -- {{ target_ip_address }}
6925
7026
- name: put configuration in place
7127
delegate_to: "{{ nginx_host }}"
7228
tags: [ configure_proxy, deploy ]
7329
become: yes
7430
template:
7531
src: "{{ item }}"
76-
dest: /etc/nginx/sites-available/{{ item }}
77-
with_items: "{{ templates }}"
78-
79-
- name: link configuration to enable
80-
delegate_to: "{{ nginx_host }}"
81-
tags: [ configure_proxy, deploy ]
82-
become: yes
83-
file:
84-
state: link
8532
dest: /etc/nginx/sites-enabled/{{ item }}
86-
src: /etc/nginx/sites-available/{{ item }}
8733
with_items: "{{ templates }}"
8834

8935
- name: reload nginx

ansible/roles/nginx-proxied-service/templates/69-navi.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ server {
3838
ssl_certificate /etc/ssl/certs/{{ user_content_domain }}/chained.pem;
3939
ssl_certificate_key /etc/ssl/certs/{{ user_content_domain }}/key.pem;
4040
ssl_trusted_certificate /etc/ssl/certs/{{ user_content_domain }}/ca.pem;
41+
ssl_dhparam /etc/ssl/certs/{{ user_content_domain }}/dhparam.pem;
4142

4243
ssl_session_cache shared:SSL:10m;
4344
ssl_session_timeout 10m;
4445

4546
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
4647
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
4748
ssl_prefer_server_ciphers on;
48-
ssl_dhparam /etc/nginx/ssl/dhparam.pem;
4949

5050
ssl_stapling on;
5151
ssl_stapling_verify on;

0 commit comments

Comments
 (0)