Merge ~pwlars/revcache/+git/revcache-charm:ssl-support into ~canonical-hw-cert/revcache/+git/revcache-charm:master

Proposed by Paul Larson
Status: Merged
Approved by: Paul Larson
Approved revision: a5135d1d62e911e0cce42886d87e09c7675cbac3
Merged at revision: 5d56cf80b1624c8027f3b92177160edf69dab9f7
Proposed branch: ~pwlars/revcache/+git/revcache-charm:ssl-support
Merge into: ~canonical-hw-cert/revcache/+git/revcache-charm:master
Diff against target: 111 lines (+73/-1)
3 files modified
metadata.yaml (+13/-0)
playbooks/revcache.yaml (+46/-1)
templates/revcache-vhost-https.conf (+14/-0)
Reviewer Review Type Date Requested Status
Paul Larson Approve
Review via email: mp+346656@code.launchpad.net

This proposal supersedes a proposal from 2018-05-17.

Description of the change

Just noticed I had submitted this against the revcache branch rather than the charm branch originally. Here's the right one.

This adds support for https to revcache, and works with or without chain certificates. It will only configure it for https if you have specified all of the necessary certificate/key files. Otherwise it will configure it for http.

I've tested this locally on my machine, and it does seem to work both with and without ssl certs specified.

To post a comment you must log in.
Revision history for this message
Paul Larson (pwlars) wrote :

I'd like to go ahead and land this and try deployment in production. Self-approving since it's not yet a production service, so if necessary, we can continue to fix/modify as needed with no ill effects

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/metadata.yaml b/metadata.yaml
2index c84b059..5697c5f 100644
3--- a/metadata.yaml
4+++ b/metadata.yaml
5@@ -8,3 +8,16 @@ tags:
6 requires:
7 db:
8 interface: redis
9+resources:
10+ ssl_certificate:
11+ type: file
12+ filename: revcache.crt
13+ description: SSL Certificate File
14+ ssl_chain:
15+ type: file
16+ filename: revcache-chain.crt
17+ description: SSL Certificate Chain File
18+ ssl_key:
19+ type: file
20+ filename: revcache.key
21+ description: SSL Key File
22diff --git a/playbooks/revcache.yaml b/playbooks/revcache.yaml
23index 74066fe..c540ff3 100644
24--- a/playbooks/revcache.yaml
25+++ b/playbooks/revcache.yaml
26@@ -2,6 +2,8 @@
27 - hosts: all
28 vars:
29 - service_dir: "/srv/revcache"
30+ - ssl_cert_location: ""
31+ - ssl_key_location: ""
32 tasks:
33 - name: set final status
34 shell: status-set active ready
35@@ -83,12 +85,55 @@
36 tags:
37 - install
38
39+ - name: Get SSL Certificate File
40+ shell: resource-get ssl_certificate || echo -n ""
41+ register: ssl_certificate
42+ tags:
43+ - config-changed
44+
45+ - name: Get SSL Certificate Chain File
46+ shell: resource-get ssl_chain || echo -n ""
47+ register: ssl_chain
48+ tags:
49+ - config-changed
50+
51+ - name: Get SSL Certificate File
52+ shell: resource-get ssl_key || echo -n ""
53+ register: ssl_key
54+ tags:
55+ - config-changed
56+
57+ - name: Copy SSL Key
58+ when: ssl_key.stdout != ""
59+ copy:
60+ src={{ ssl_key.stdout }}
61+ dest=/etc/ssl/private/revcache.key
62+ tags:
63+ - config-changed
64+
65+ - name: Copy SSL certificate
66+ when: ssl_certificate.stdout != ""
67+ shell: cat {{ ssl_certificate.stdout }} {{ ssl_chain.stdout }} > /etc/ssl/certs/revcache.crt
68+ tags:
69+ - config-changed
70+
71 - name: Copy nginx site config file
72+ when: ssl_key.stdout == "" and
73+ ssl_certificate.stdout == ""
74 copy:
75 src: "{{ charm_dir }}/templates/revcache-vhost.conf"
76 dest: "/etc/nginx/sites-enabled/revcache"
77 tags:
78- - install
79+ - config-changed
80+
81+ - name: Copy nginx site config file
82+ when: ssl_key.stdout != "" and
83+ ssl_certificate.stdout != ""
84+ copy:
85+ src: "{{ charm_dir }}/templates/revcache-vhost-https.conf"
86+ dest: "/etc/nginx/sites-enabled/revcache"
87+ tags:
88+ - config-changed
89
90 - name: Start revcache
91 service:
92diff --git a/templates/revcache-vhost-https.conf b/templates/revcache-vhost-https.conf
93new file mode 100644
94index 0000000..9bb269b
95--- /dev/null
96+++ b/templates/revcache-vhost-https.conf
97@@ -0,0 +1,14 @@
98+server {
99+ listen 443 ssl;
100+ server_name localhost;
101+ ssl_certificate /etc/ssl/certs/revcache.crt;
102+ ssl_certificate_key /etc/ssl/private/revcache.key;
103+ location / {
104+ include proxy_params;
105+ proxy_pass http://localhost:8000;
106+ }
107+ location /basic_status {
108+ stub_status;
109+ }
110+ error_log /var/log/revcache-nginx-error.log warn;
111+}

Subscribers

People subscribed via source and target branches