Merge lp:~hatch/charms/precise/ghost/trunk into lp:charms/ghost

Proposed by Jeff Pihach
Status: Merged
Merged at revision: 6
Proposed branch: lp:~hatch/charms/precise/ghost/trunk
Merge into: lp:charms/ghost
Diff against target: 456 lines (+238/-58)
8 files modified
README.md (+142/-53)
assets/config.js.template (+13/-0)
assets/ghost.conf (+1/-1)
config.yaml (+37/-0)
hooks/config-changed (+42/-1)
hooks/install (+1/-1)
revision (+1/-1)
utils/utils.js (+1/-1)
To merge this branch: bzr merge lp:~hatch/charms/precise/ghost/trunk
Reviewer Review Type Date Requested Status
José Antonio Rey (community) Approve
Review Queue (community) automated testing Needs Fixing
Review via email: mp+243044@code.launchpad.net

Description of the change

Committing revno dce85f67e3 from https://github.com/hatched/ghost-charm

To post a comment you must log in.
Revision history for this message
Review Queue (review-queue) wrote :

This items has failed automated testing! Results available here http://reports.vapour.ws/charm-tests/charm-bundle-test-10463-results

review: Needs Fixing (automated testing)
Revision history for this message
José Antonio Rey (jose) wrote :

Hey Jeff!

I just ran the tests on this MP, and it looks good to me. +1!

Thanks for improving the charm!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README.md'
2--- README.md 2014-06-22 22:53:50 +0000
3+++ README.md 2014-11-27 14:38:00 +0000
4@@ -7,23 +7,28 @@
5
6 This Ghost charm allows you to trivially deploy a horizontally scalable, load
7 balanced, instance of the Ghost blogging platform locally or on a cloud
8-provider of choice.
9+provider of choice using Juju.
10
11-To deploy this charm you will need a cloud environment, a working juju
12+To deploy this charm you will need a cloud environment, a working Juju
13 installation and a successful bootstrap. If you don't have Juju installed and an
14-environment set up see [Getting Started With Juju](https://juju.ubuntu.com/docs/getting-started.html).
15+environment set up see
16+[Getting Started With Juju](https://jujucharms.com/docs/getting-started).
17
18 - [Quick Start](#quick-start)
19 - [Configuration](#configuration)
20+- [Using A Load Balancer](#using-a-load-balancer)
21+- [Setting Up Email Service](#setting-up-email-service)
22 - [Connecting To Mysql](#connecting-to-mysql)
23 - [Horizontal Scaling](#horizontal-scaling)
24-- [Load Balancing](#load-balancing)
25-- [Wrap Up](#wrap-up)
26+- [Colocating On A Single Machine](#colocating-on-a-single-machine)
27+- [Deploying And Using The GUI](#deploying-and-using-the-gui)
28 - [Contributing](#contributing)
29 - [Bug Reports](#bug-reports)
30
31 # Quick Start
32
33+After you have a Juju cloud environment running:
34+
35 $ juju deploy ghost
36 $ juju expose ghost
37
38@@ -32,25 +37,37 @@
39 $ juju status ghost
40
41 Visit `<your URL>:2368/ghost/signup/` to create your username and password.
42-Continue setting up Ghost by following the [usage documentation](http://docs.ghost.org/usage/).
43+Continue setting up Ghost by following the
44+[usage documentation](http://docs.ghost.org/usage/).
45
46 You will want to change the URL that Ghost uses to generate links internally to
47 the URL you will be using for your blog.
48
49 $ juju set ghost url=<your url>
50
51-If you will only be running a single instance of Ghost without any load
52-balancing or reverse proxy then you will also want to set the listening port.
53+The ghost charm is designed to not run as a user which has access to reserved
54+ports. This means that if you want to run your blog on port 80 or 443 you will
55+need to deploy and relate this charm to Apache. This has the added benefit of
56+being able to load balance between any additional Ghost units and do url
57+redirection if necessary. See
58+[Using A Load Balancer](#using-a-load-balancer) for more information.
59
60- $juju set ghost port=80
61+In order to allow Ghost to send emails for things like new user validation and
62+password resets you will want to set up the email service. See
63+[Setting Up Email Service](#setting-up-email-service) for more information.
64
65 It's also recommended, although not required, that you use a MySQL database
66-instead of the internal SQLite database. See [Connecting To MySQL](#connecting-to-mysql)
67-for more information.
68+instead of the internal SQLite database. See
69+[Connecting To MySQL](#connecting-to-mysql) for more information.
70+
71+All of the instructions in this readme are provided using Juju's CLI interface.
72+Juju also has an amazing GUI which is highly recommended for beginners to Juju.
73+For information on how to deploy the GUI and use it with this charm see
74+[Deploying And Using The GUI](#deploying-and-using-the-gui)
75
76 # Configuration
77
78-To view the configuration options for this charm:
79+To view the configuration options for this charm open the `config.yaml` file or:
80
81 $ juju get ghost
82
83@@ -58,17 +75,72 @@
84
85 $ juju set ghost <key>=<value>
86
87-To set the URL which ghost uses when generating links:
88-
89- $ juju set ghost url=http://my-ghost-blog.com
90-
91-To set the host to be passed to node's net.Server listen():
92-
93- $ juju set ghost host=0.0.0.0
94-
95-To set the port to be passed to node's net.Server listen():
96-
97- $ juju set ghost port=2368
98+See the `config.yaml` file in the charm for a detailed list of all of the charms
99+configuration options.
100+
101+
102+# Using A Load Balancer
103+
104+In order to run multiple instances of the Ghost web server and to be able to
105+serve your blog on a reserved port this charm supports being load balanced and
106+reverse proxied by [haproxy](https://jujucharms.com/haproxy/trusty).
107+
108+In order to reverse proxy and load balance this service you will need to deploy
109+haproxy:
110+
111+ $ juju deploy haproxy
112+ $ juju expose haproxy
113+
114+You will then need to unexpose the Ghost service:
115+
116+ $ juju unexpose ghost
117+
118+You now need to let your haproxy instance know about Ghost so that it can
119+make the appropriate adjustments.
120+
121+ $ juju add-relation ghost haproxy
122+
123+After a few moments of configuration your Ghost blog will now be reachable on
124+port 80 and you will be able to horizontally scale the server and have it
125+automatically load balanced. See [Horizontal Scaling](#horizontal-scaling) for
126+more information.
127+
128+
129+# Setting Up Email Service
130+
131+Ghost needs the ability to send emails to users for things like new user
132+validation and password resets. To accomplish this Ghost supports using a
133+third party email service which it can communicate with to send these emails.
134+Ghost, and this charm, supports sending emails using Mailgun, Amazon SES, and
135+Gmail. Additional information about why Ghost needs this service and it's
136+supported platforms see [Mail configuration](http://support.ghost.org/mail/).
137+
138+To specify a supported email service to use you simply need to set the
139+configuration values in the charm and they will be generated for your Ghost
140+instance.
141+
142+#### Mailgun & Gmail
143+
144+ $ juju set ghost mailserver_username=<your username>
145+ $ juju set ghost mailserver_password=<your password>
146+ Then
147+ $ juju set ghost mail_service=Mailgun
148+ -or-
149+ $ juju set ghost mail_service=Gmail
150+
151+#### Amazon SES
152+
153+ $ juju set ghost mailserver_username=<your username>
154+ $ juju set ghost mailserver_password=<your password>
155+ $ juju set ghost amazon_ses_host=<your ses host>
156+ Then
157+ $ juju set ghost mail_service=SES
158+
159+After this has been completed your Ghost server will restart and Ghost will
160+now be able to send emails using that provider. It's recommended to test this
161+before you need it by creating a new user and pointing it to an email you
162+control and ensure that you get the validation email.
163+
164
165 # Connecting To MySQL
166
167@@ -84,14 +156,15 @@
168 $ juju deploy mysql
169
170 Additional details about the MySQL charm and configuration can be found in the
171-[MySQL charm details](http://manage.jujucharms.com/charms/precise/mysql) page.
172+[MySQL charm details](https://jujucharms.com/mysql/precise/) page.
173
174 You'll then need to relate the Ghost blog service to the MySQL service.
175
176 $ juju add-relation ghost mysql
177
178-The charm will handle all settings necessary to use the MySQL database instead
179-of the internal SQLite database.
180+The charm will then handle setting up all configuration options necessary to use
181+the MySQL database instead of the internal SQLite database.
182+
183
184 # Horizontal Scaling
185
186@@ -101,36 +174,52 @@
187
188 $ juju add-unit -n 1 ghost
189
190-Now that you have more than one unit you will need to load balance between
191-them. See [Load Balancing](#load-balancing) for more information.
192-
193-# Load Balancing
194-
195-This charm supports being load balanced and reverse proxied by [haproxy](http://manage.jujucharms.com/charms/precise/haproxy)
196-or [apache2](http://manage.jujucharms.com/charms/precise/apache2).
197-
198-In order to load balance this service you will need to deploy one of the
199-aforementioned charms:
200-
201- $ juju deploy haproxy
202-
203-You will then need to unexpose the Ghost service:
204-
205- $ juju unexpose ghost
206-
207-And change the port at which it listens from 80:
208-
209- $ juju set ghost port=2368
210-
211-You now need to let your haproxy instance know about Ghost so that it can
212-make the appropriate adjustments.
213-
214- $ juju add-relation ghost haproxy
215+Now that you have more than one unit you will need to ensure your posts are not
216+stored locally on a single unit and you will need to be able to load balance
217+between the multiple instances. See
218+[Using A Load Balancer](#using-a-load-balancer) and
219+[Connecting To MySQL](#connecting-to-mysql) for more information.
220+
221+
222+# Colocating On A Single Machine
223+
224+By default, every time you deploy a service or create a new unit Juju will
225+create a new instance on your cloud provider. This may be undesired due to
226+hardware availability or budgeting. Juju also provides you an easy to use method
227+to deploy all of these services to a smaller number of machines using the
228+following syntax:
229+
230+ $ juju deploy --to=<machine number> <service name>
231+
232+ ex)
233+
234+ $ juju deploy --to=1 ghost
235+
236+Colocating can have unintended consequences if the multiple service were not
237+designed to be deployed to the same machine. To get around this you're able to
238+create LXC and KVM containers to deploy to. This gets into advanced Juju usage
239+and more information can be found in the Juju documentation on
240+[Deploying Charms](https://jujucharms.com/docs/charms-deploying#deploying-to-specific-machines-and-containers)
241+
242+# Deploying And Using The GUI
243+
244+Juju has a powerful graphical user interface which you can use to interact with
245+your environment without having to use the CLI. In order to use the GUI in
246+your environment you will need to deploy it:
247+
248+ $ juju deploy juju-gui
249+
250+Every command in this readme can be done using the GUI instead of the CLI. See
251+[Juju GUI](https://jujucharms.com/juju-gui/trusty) for detailed information on
252+the Juju GUI charm and how to use the GUI.
253+
254
255 # Contributing
256
257 This charm wouldn't be where it is today without great contributions from
258-others. Pull requests are accepted in the [ghost-charm repository](https://github.com/hatched/ghost-charm)
259+others. Pull requests are accepted in the
260+[ghost-charm repository](https://github.com/hatched/ghost-charm)
261+
262
263 # Bug Reports
264
265@@ -141,6 +230,6 @@
266 If you have found a bug with the ghost-charm itself they can be filed in the
267 [ghost-charm repository](https://github.com/hatched/ghost-charm). Please include
268 exact steps to reproduce the issue and be as detailed as possible, including
269-what version of Ubuntu you're running, the version of this charm you have
270+what version of Ubuntu you're running on, the version of this charm you have
271 deployed, the cloud your environment is running on, any other charms deployed to
272 the environment.
273
274=== removed file 'assets/Ghost-0.4.2.zip'
275Binary files assets/Ghost-0.4.2.zip 2014-06-22 22:53:50 +0000 and assets/Ghost-0.4.2.zip 1970-01-01 00:00:00 +0000 differ
276=== added file 'assets/Ghost-0.5.5.zip'
277Binary files assets/Ghost-0.5.5.zip 1970-01-01 00:00:00 +0000 and assets/Ghost-0.5.5.zip 2014-11-27 14:38:00 +0000 differ
278=== modified file 'assets/config.js.template'
279--- assets/config.js.template 2014-06-22 22:53:50 +0000
280+++ assets/config.js.template 2014-11-27 14:38:00 +0000
281@@ -7,6 +7,19 @@
282 server: {
283 host: '{{host}}',
284 port: '{{port}}'
285+ },
286+ mail: {
287+ {{from_address}}
288+ {{amazon_ses_host}}
289+ transport: 'SMTP',
290+ options: {
291+ service: '{{mail_service}}',
292+ {{amazon_ses_port}}
293+ auth: {
294+ user: '{{mailserver_username}}',
295+ pass: '{{mailserver_password}}'
296+ }
297+ }
298 }
299 }
300 };
301
302=== modified file 'assets/ghost.conf'
303--- assets/ghost.conf 2014-06-22 22:53:50 +0000
304+++ assets/ghost.conf 2014-11-27 14:38:00 +0000
305@@ -1,6 +1,6 @@
306 #/etc/init/ghost.conf
307 description "Ghost Blog"
308-author "Jeff Pihach <jeff.pihach@canonical.com>"
309+author "Jeff Pihach <jpihach@gmail.com>"
310
311 setuid ubuntu
312
313
314=== modified file 'config.yaml'
315--- config.yaml 2014-05-22 05:51:19 +0000
316+++ config.yaml 2014-11-27 14:38:00 +0000
317@@ -11,3 +11,40 @@
318 description: Port to be passed to node's net.Server listen().
319 type: int
320 default: 2368
321+ mail_service:
322+ description: |
323+ Pick one of the supported email services to allow Ghost to send emails
324+ for things like password recovery and new user acceptance. Valid options
325+ will require the corresponding username and password fields filled out
326+ below. The supported values are 'Mailgun', 'SES', and 'Gmail'.
327+ An empty value will remove the configuration from Ghost.
328+ type: string
329+ default: ''
330+ mailserver_username:
331+ description: |
332+ Username for the mail service chosen above. Information on where to find
333+ these credentials can be found here: http://support.ghost.org/mail/ .
334+ type: string
335+ default: ''
336+ mailserver_password:
337+ description: |
338+ Password for the mail service chosen above. Information on where to find
339+ these credentials can be found here: http://support.ghost.org/mail/ .
340+ type: string
341+ default: ''
342+ amazon_ses_host:
343+ description: |
344+ The host value for your Amazon SES account. This is only necessary if
345+ you chose this option in the mail_service field above.
346+ type: string
347+ default: ''
348+ from_address:
349+ description: |
350+ By default the ‘from’ address for mail sent from Ghost will be set to
351+ "Blog Title <ghost@your-ghost-blog.com>" where 'Blog Title' is the title
352+ you have set in settings, and 'your-ghost-blog.com' is the value from
353+ the host configuration value above. You can override this value here.
354+ Supported formats are 'myemail@example.com' or
355+ 'Custom Name <myemail@example.com'.
356+ type: string
357+ default: ''
358
359=== modified file 'hooks/config-changed'
360--- hooks/config-changed 2014-06-22 22:53:50 +0000
361+++ hooks/config-changed 2014-11-27 14:38:00 +0000
362@@ -16,7 +16,7 @@
363 function updateConfig(error, config) {
364 try {
365 exec('juju-log "Closing old port..."');
366- oldConfig = require('/var/www/ghost/config.js');
367+ var oldConfig = require('/var/www/ghost/config.js');
368 exec('close-port ' + oldConfig.production.server.port + '/TCP',
369 function() {
370 exec('juju-log "Old port closed."');
371@@ -26,6 +26,7 @@
372 exec('juju-log "config.js does not exist yet; port not closed"');
373 }
374 config = JSON.parse(config);
375+ config = buildEmailConfig(config);
376 utils.renderTemplate(
377 config, 'config.js.template', '/var/www/ghost/config.js');
378 exec('chown -R ubuntu:ubuntu /var/www/ghost');
379@@ -38,4 +39,44 @@
380 dbutils.configureSqlite();
381 }
382
383+/*
384+ Generates the appropriate configuration object for the email provider.
385+
386+ @method buildEmailConfig
387+ @param {Object} config The configuration field values.
388+ @return {Object} A modified configuration object containing the correct email
389+ configuration options.
390+*/
391+function buildEmailConfig(config) {
392+ // Setting this here to nothing because it'll be set as the real value later
393+ // on if needed.
394+ config.amazon_ses_port = '';
395+ // If we don't have a valid service name or it's an empty value then return
396+ // with the currently modified values.
397+ var valid_services = ['Mailgun', 'SES', 'Gmail'];
398+ if (config.mail_service === '' ||
399+ valid_services.indexOf(config.mail_service) < 0) {
400+ // If the mail_service field is empty or unset then we want to disable
401+ // the email server by leaving the provider field in the config blank.
402+ exec(
403+ 'juju-log "The provided value `' + config.mail_service + '`' +
404+ ' is not a valid configuration option for the `mail_service`.' +
405+ ' See the configuration details for more information. Skipping' +
406+ ' email provider');
407+ config.mail_service = '';
408+ return config;
409+ }
410+ // The remaining options require the entire key/value pair to be written
411+ // into the template.
412+ if (config.from_address !== '') {
413+ config.from_address = 'from: ' + config.from_address + ',';
414+ }
415+ if (config.mail_service === 'SES') {
416+ config.amazon_ses_host = 'host: ' + config.amazon_ses_host + ',';
417+ config.amazon_ses_port = 'port: 465,';
418+ }
419+
420+ return config;
421+}
422+
423 exec('config-get --all --format=json', updateConfig);
424
425=== modified file 'hooks/install'
426--- hooks/install 2014-06-22 22:53:50 +0000
427+++ hooks/install 2014-11-27 14:38:00 +0000
428@@ -17,7 +17,7 @@
429 chmod 644 /etc/init/ghost.conf
430 # Unzip and move to it's proper location
431 mkdir -p /var/www/ghost
432-unzip -uo assets/Ghost-0.4.2.zip -d /var/www/ghost
433+unzip -uo assets/Ghost-0.5.5.zip -d /var/www/ghost
434
435 cd /var/www/ghost
436 npm install --production
437
438=== modified file 'revision'
439--- revision 2014-06-22 22:53:50 +0000
440+++ revision 2014-11-27 14:38:00 +0000
441@@ -1,1 +1,1 @@
442-5
443+7
444
445=== modified file 'utils/utils.js'
446--- utils/utils.js 2013-11-26 03:43:17 +0000
447+++ utils/utils.js 2014-11-27 14:38:00 +0000
448@@ -7,7 +7,7 @@
449 @method renderTemplateData
450 @param {Object} data Config data
451 @param {String} template The template filename
452- @param {String} filepath Path to render the template out to
453+ @param {String} filepath Path to render the template out to
454 */
455 function renderTemplate(data, template, filepath) {
456 var fileData = fs.readFileSync(path.join('assets', template), 'utf8');

Subscribers

People subscribed via source and target branches

to all changes: