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
=== modified file 'README.md'
--- README.md 2014-06-22 22:53:50 +0000
+++ README.md 2014-11-27 14:38:00 +0000
@@ -7,23 +7,28 @@
77
8This Ghost charm allows you to trivially deploy a horizontally scalable, load8This Ghost charm allows you to trivially deploy a horizontally scalable, load
9balanced, instance of the Ghost blogging platform locally or on a cloud9balanced, instance of the Ghost blogging platform locally or on a cloud
10provider of choice.10provider of choice using Juju.
1111
12To deploy this charm you will need a cloud environment, a working juju12To deploy this charm you will need a cloud environment, a working Juju
13installation and a successful bootstrap. If you don't have Juju installed and an13installation and a successful bootstrap. If you don't have Juju installed and an
14environment set up see [Getting Started With Juju](https://juju.ubuntu.com/docs/getting-started.html).14environment set up see
15[Getting Started With Juju](https://jujucharms.com/docs/getting-started).
1516
16- [Quick Start](#quick-start)17- [Quick Start](#quick-start)
17- [Configuration](#configuration)18- [Configuration](#configuration)
19- [Using A Load Balancer](#using-a-load-balancer)
20- [Setting Up Email Service](#setting-up-email-service)
18- [Connecting To Mysql](#connecting-to-mysql)21- [Connecting To Mysql](#connecting-to-mysql)
19- [Horizontal Scaling](#horizontal-scaling)22- [Horizontal Scaling](#horizontal-scaling)
20- [Load Balancing](#load-balancing)23- [Colocating On A Single Machine](#colocating-on-a-single-machine)
21- [Wrap Up](#wrap-up)24- [Deploying And Using The GUI](#deploying-and-using-the-gui)
22- [Contributing](#contributing)25- [Contributing](#contributing)
23- [Bug Reports](#bug-reports)26- [Bug Reports](#bug-reports)
2427
25# Quick Start28# Quick Start
2629
30After you have a Juju cloud environment running:
31
27 $ juju deploy ghost32 $ juju deploy ghost
28 $ juju expose ghost33 $ juju expose ghost
2934
@@ -32,25 +37,37 @@
32 $ juju status ghost37 $ juju status ghost
3338
34Visit `<your URL>:2368/ghost/signup/` to create your username and password.39Visit `<your URL>:2368/ghost/signup/` to create your username and password.
35Continue setting up Ghost by following the [usage documentation](http://docs.ghost.org/usage/).40Continue setting up Ghost by following the
41[usage documentation](http://docs.ghost.org/usage/).
3642
37You will want to change the URL that Ghost uses to generate links internally to43You will want to change the URL that Ghost uses to generate links internally to
38the URL you will be using for your blog.44the URL you will be using for your blog.
3945
40 $ juju set ghost url=<your url>46 $ juju set ghost url=<your url>
4147
42If you will only be running a single instance of Ghost without any load48The ghost charm is designed to not run as a user which has access to reserved
43balancing or reverse proxy then you will also want to set the listening port.49ports. This means that if you want to run your blog on port 80 or 443 you will
50need to deploy and relate this charm to Apache. This has the added benefit of
51being able to load balance between any additional Ghost units and do url
52redirection if necessary. See
53[Using A Load Balancer](#using-a-load-balancer) for more information.
4454
45 $juju set ghost port=8055In order to allow Ghost to send emails for things like new user validation and
56password resets you will want to set up the email service. See
57[Setting Up Email Service](#setting-up-email-service) for more information.
4658
47It's also recommended, although not required, that you use a MySQL database59It's also recommended, although not required, that you use a MySQL database
48instead of the internal SQLite database. See [Connecting To MySQL](#connecting-to-mysql)60instead of the internal SQLite database. See
49for more information.61[Connecting To MySQL](#connecting-to-mysql) for more information.
62
63All of the instructions in this readme are provided using Juju's CLI interface.
64Juju also has an amazing GUI which is highly recommended for beginners to Juju.
65For information on how to deploy the GUI and use it with this charm see
66[Deploying And Using The GUI](#deploying-and-using-the-gui)
5067
51# Configuration68# Configuration
5269
53To view the configuration options for this charm:70To view the configuration options for this charm open the `config.yaml` file or:
5471
55 $ juju get ghost72 $ juju get ghost
5673
@@ -58,17 +75,72 @@
5875
59 $ juju set ghost <key>=<value>76 $ juju set ghost <key>=<value>
6077
61To set the URL which ghost uses when generating links:78See the `config.yaml` file in the charm for a detailed list of all of the charms
6279configuration options.
63 $ juju set ghost url=http://my-ghost-blog.com80
6481
65To set the host to be passed to node's net.Server listen():82# Using A Load Balancer
6683
67 $ juju set ghost host=0.0.0.084In order to run multiple instances of the Ghost web server and to be able to
6885serve your blog on a reserved port this charm supports being load balanced and
69To set the port to be passed to node's net.Server listen():86reverse proxied by [haproxy](https://jujucharms.com/haproxy/trusty).
7087
71 $ juju set ghost port=236888In order to reverse proxy and load balance this service you will need to deploy
89haproxy:
90
91 $ juju deploy haproxy
92 $ juju expose haproxy
93
94You will then need to unexpose the Ghost service:
95
96 $ juju unexpose ghost
97
98You now need to let your haproxy instance know about Ghost so that it can
99make the appropriate adjustments.
100
101 $ juju add-relation ghost haproxy
102
103After a few moments of configuration your Ghost blog will now be reachable on
104port 80 and you will be able to horizontally scale the server and have it
105automatically load balanced. See [Horizontal Scaling](#horizontal-scaling) for
106more information.
107
108
109# Setting Up Email Service
110
111Ghost needs the ability to send emails to users for things like new user
112validation and password resets. To accomplish this Ghost supports using a
113third party email service which it can communicate with to send these emails.
114Ghost, and this charm, supports sending emails using Mailgun, Amazon SES, and
115Gmail. Additional information about why Ghost needs this service and it's
116supported platforms see [Mail configuration](http://support.ghost.org/mail/).
117
118To specify a supported email service to use you simply need to set the
119configuration values in the charm and they will be generated for your Ghost
120instance.
121
122#### Mailgun & Gmail
123
124 $ juju set ghost mailserver_username=<your username>
125 $ juju set ghost mailserver_password=<your password>
126 Then
127 $ juju set ghost mail_service=Mailgun
128 -or-
129 $ juju set ghost mail_service=Gmail
130
131#### Amazon SES
132
133 $ juju set ghost mailserver_username=<your username>
134 $ juju set ghost mailserver_password=<your password>
135 $ juju set ghost amazon_ses_host=<your ses host>
136 Then
137 $ juju set ghost mail_service=SES
138
139After this has been completed your Ghost server will restart and Ghost will
140now be able to send emails using that provider. It's recommended to test this
141before you need it by creating a new user and pointing it to an email you
142control and ensure that you get the validation email.
143
72144
73# Connecting To MySQL145# Connecting To MySQL
74146
@@ -84,14 +156,15 @@
84 $ juju deploy mysql156 $ juju deploy mysql
85157
86Additional details about the MySQL charm and configuration can be found in the158Additional details about the MySQL charm and configuration can be found in the
87[MySQL charm details](http://manage.jujucharms.com/charms/precise/mysql) page.159[MySQL charm details](https://jujucharms.com/mysql/precise/) page.
88160
89You'll then need to relate the Ghost blog service to the MySQL service.161You'll then need to relate the Ghost blog service to the MySQL service.
90162
91 $ juju add-relation ghost mysql163 $ juju add-relation ghost mysql
92164
93The charm will handle all settings necessary to use the MySQL database instead165The charm will then handle setting up all configuration options necessary to use
94of the internal SQLite database.166the MySQL database instead of the internal SQLite database.
167
95168
96# Horizontal Scaling169# Horizontal Scaling
97170
@@ -101,36 +174,52 @@
101174
102 $ juju add-unit -n 1 ghost175 $ juju add-unit -n 1 ghost
103176
104Now that you have more than one unit you will need to load balance between177Now that you have more than one unit you will need to ensure your posts are not
105them. See [Load Balancing](#load-balancing) for more information.178stored locally on a single unit and you will need to be able to load balance
106179between the multiple instances. See
107# Load Balancing180[Using A Load Balancer](#using-a-load-balancer) and
108181[Connecting To MySQL](#connecting-to-mysql) for more information.
109This charm supports being load balanced and reverse proxied by [haproxy](http://manage.jujucharms.com/charms/precise/haproxy)182
110or [apache2](http://manage.jujucharms.com/charms/precise/apache2).183
111184# Colocating On A Single Machine
112In order to load balance this service you will need to deploy one of the185
113aforementioned charms:186By default, every time you deploy a service or create a new unit Juju will
114187create a new instance on your cloud provider. This may be undesired due to
115 $ juju deploy haproxy188hardware availability or budgeting. Juju also provides you an easy to use method
116189to deploy all of these services to a smaller number of machines using the
117You will then need to unexpose the Ghost service:190following syntax:
118191
119 $ juju unexpose ghost192 $ juju deploy --to=<machine number> <service name>
120193
121And change the port at which it listens from 80:194 ex)
122195
123 $ juju set ghost port=2368196 $ juju deploy --to=1 ghost
124197
125You now need to let your haproxy instance know about Ghost so that it can198Colocating can have unintended consequences if the multiple service were not
126make the appropriate adjustments.199designed to be deployed to the same machine. To get around this you're able to
127200create LXC and KVM containers to deploy to. This gets into advanced Juju usage
128 $ juju add-relation ghost haproxy201and more information can be found in the Juju documentation on
202[Deploying Charms](https://jujucharms.com/docs/charms-deploying#deploying-to-specific-machines-and-containers)
203
204# Deploying And Using The GUI
205
206Juju has a powerful graphical user interface which you can use to interact with
207your environment without having to use the CLI. In order to use the GUI in
208your environment you will need to deploy it:
209
210 $ juju deploy juju-gui
211
212Every command in this readme can be done using the GUI instead of the CLI. See
213[Juju GUI](https://jujucharms.com/juju-gui/trusty) for detailed information on
214the Juju GUI charm and how to use the GUI.
215
129216
130# Contributing217# Contributing
131218
132This charm wouldn't be where it is today without great contributions from219This charm wouldn't be where it is today without great contributions from
133others. Pull requests are accepted in the [ghost-charm repository](https://github.com/hatched/ghost-charm)220others. Pull requests are accepted in the
221[ghost-charm repository](https://github.com/hatched/ghost-charm)
222
134223
135# Bug Reports224# Bug Reports
136225
@@ -141,6 +230,6 @@
141If you have found a bug with the ghost-charm itself they can be filed in the230If you have found a bug with the ghost-charm itself they can be filed in the
142[ghost-charm repository](https://github.com/hatched/ghost-charm). Please include231[ghost-charm repository](https://github.com/hatched/ghost-charm). Please include
143exact steps to reproduce the issue and be as detailed as possible, including232exact steps to reproduce the issue and be as detailed as possible, including
144what version of Ubuntu you're running, the version of this charm you have233what version of Ubuntu you're running on, the version of this charm you have
145deployed, the cloud your environment is running on, any other charms deployed to234deployed, the cloud your environment is running on, any other charms deployed to
146the environment.235the environment.
147236
=== removed file 'assets/Ghost-0.4.2.zip'
148Binary 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 differ237Binary 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
=== added file 'assets/Ghost-0.5.5.zip'
149Binary 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 differ238Binary 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
=== modified file 'assets/config.js.template'
--- assets/config.js.template 2014-06-22 22:53:50 +0000
+++ assets/config.js.template 2014-11-27 14:38:00 +0000
@@ -7,6 +7,19 @@
7 server: {7 server: {
8 host: '{{host}}',8 host: '{{host}}',
9 port: '{{port}}'9 port: '{{port}}'
10 },
11 mail: {
12 {{from_address}}
13 {{amazon_ses_host}}
14 transport: 'SMTP',
15 options: {
16 service: '{{mail_service}}',
17 {{amazon_ses_port}}
18 auth: {
19 user: '{{mailserver_username}}',
20 pass: '{{mailserver_password}}'
21 }
22 }
10 }23 }
11 }24 }
12};25};
1326
=== modified file 'assets/ghost.conf'
--- assets/ghost.conf 2014-06-22 22:53:50 +0000
+++ assets/ghost.conf 2014-11-27 14:38:00 +0000
@@ -1,6 +1,6 @@
1#/etc/init/ghost.conf1#/etc/init/ghost.conf
2description "Ghost Blog"2description "Ghost Blog"
3author "Jeff Pihach <jeff.pihach@canonical.com>"3author "Jeff Pihach <jpihach@gmail.com>"
44
5setuid ubuntu5setuid ubuntu
66
77
=== modified file 'config.yaml'
--- config.yaml 2014-05-22 05:51:19 +0000
+++ config.yaml 2014-11-27 14:38:00 +0000
@@ -11,3 +11,40 @@
11 description: Port to be passed to node's net.Server listen().11 description: Port to be passed to node's net.Server listen().
12 type: int12 type: int
13 default: 236813 default: 2368
14 mail_service:
15 description: |
16 Pick one of the supported email services to allow Ghost to send emails
17 for things like password recovery and new user acceptance. Valid options
18 will require the corresponding username and password fields filled out
19 below. The supported values are 'Mailgun', 'SES', and 'Gmail'.
20 An empty value will remove the configuration from Ghost.
21 type: string
22 default: ''
23 mailserver_username:
24 description: |
25 Username for the mail service chosen above. Information on where to find
26 these credentials can be found here: http://support.ghost.org/mail/ .
27 type: string
28 default: ''
29 mailserver_password:
30 description: |
31 Password for the mail service chosen above. Information on where to find
32 these credentials can be found here: http://support.ghost.org/mail/ .
33 type: string
34 default: ''
35 amazon_ses_host:
36 description: |
37 The host value for your Amazon SES account. This is only necessary if
38 you chose this option in the mail_service field above.
39 type: string
40 default: ''
41 from_address:
42 description: |
43 By default the ‘from’ address for mail sent from Ghost will be set to
44 "Blog Title <ghost@your-ghost-blog.com>" where 'Blog Title' is the title
45 you have set in settings, and 'your-ghost-blog.com' is the value from
46 the host configuration value above. You can override this value here.
47 Supported formats are 'myemail@example.com' or
48 'Custom Name <myemail@example.com'.
49 type: string
50 default: ''
1451
=== modified file 'hooks/config-changed'
--- hooks/config-changed 2014-06-22 22:53:50 +0000
+++ hooks/config-changed 2014-11-27 14:38:00 +0000
@@ -16,7 +16,7 @@
16function updateConfig(error, config) {16function updateConfig(error, config) {
17 try {17 try {
18 exec('juju-log "Closing old port..."');18 exec('juju-log "Closing old port..."');
19 oldConfig = require('/var/www/ghost/config.js');19 var oldConfig = require('/var/www/ghost/config.js');
20 exec('close-port ' + oldConfig.production.server.port + '/TCP',20 exec('close-port ' + oldConfig.production.server.port + '/TCP',
21 function() {21 function() {
22 exec('juju-log "Old port closed."');22 exec('juju-log "Old port closed."');
@@ -26,6 +26,7 @@
26 exec('juju-log "config.js does not exist yet; port not closed"');26 exec('juju-log "config.js does not exist yet; port not closed"');
27 }27 }
28 config = JSON.parse(config);28 config = JSON.parse(config);
29 config = buildEmailConfig(config);
29 utils.renderTemplate(30 utils.renderTemplate(
30 config, 'config.js.template', '/var/www/ghost/config.js');31 config, 'config.js.template', '/var/www/ghost/config.js');
31 exec('chown -R ubuntu:ubuntu /var/www/ghost');32 exec('chown -R ubuntu:ubuntu /var/www/ghost');
@@ -38,4 +39,44 @@
38 dbutils.configureSqlite();39 dbutils.configureSqlite();
39}40}
4041
42/*
43 Generates the appropriate configuration object for the email provider.
44
45 @method buildEmailConfig
46 @param {Object} config The configuration field values.
47 @return {Object} A modified configuration object containing the correct email
48 configuration options.
49*/
50function buildEmailConfig(config) {
51 // Setting this here to nothing because it'll be set as the real value later
52 // on if needed.
53 config.amazon_ses_port = '';
54 // If we don't have a valid service name or it's an empty value then return
55 // with the currently modified values.
56 var valid_services = ['Mailgun', 'SES', 'Gmail'];
57 if (config.mail_service === '' ||
58 valid_services.indexOf(config.mail_service) < 0) {
59 // If the mail_service field is empty or unset then we want to disable
60 // the email server by leaving the provider field in the config blank.
61 exec(
62 'juju-log "The provided value `' + config.mail_service + '`' +
63 ' is not a valid configuration option for the `mail_service`.' +
64 ' See the configuration details for more information. Skipping' +
65 ' email provider');
66 config.mail_service = '';
67 return config;
68 }
69 // The remaining options require the entire key/value pair to be written
70 // into the template.
71 if (config.from_address !== '') {
72 config.from_address = 'from: ' + config.from_address + ',';
73 }
74 if (config.mail_service === 'SES') {
75 config.amazon_ses_host = 'host: ' + config.amazon_ses_host + ',';
76 config.amazon_ses_port = 'port: 465,';
77 }
78
79 return config;
80}
81
41exec('config-get --all --format=json', updateConfig);82exec('config-get --all --format=json', updateConfig);
4283
=== modified file 'hooks/install'
--- hooks/install 2014-06-22 22:53:50 +0000
+++ hooks/install 2014-11-27 14:38:00 +0000
@@ -17,7 +17,7 @@
17chmod 644 /etc/init/ghost.conf17chmod 644 /etc/init/ghost.conf
18# Unzip and move to it's proper location18# Unzip and move to it's proper location
19mkdir -p /var/www/ghost19mkdir -p /var/www/ghost
20unzip -uo assets/Ghost-0.4.2.zip -d /var/www/ghost20unzip -uo assets/Ghost-0.5.5.zip -d /var/www/ghost
2121
22cd /var/www/ghost22cd /var/www/ghost
23npm install --production23npm install --production
2424
=== modified file 'revision'
--- revision 2014-06-22 22:53:50 +0000
+++ revision 2014-11-27 14:38:00 +0000
@@ -1,1 +1,1 @@
1517
22
=== modified file 'utils/utils.js'
--- utils/utils.js 2013-11-26 03:43:17 +0000
+++ utils/utils.js 2014-11-27 14:38:00 +0000
@@ -7,7 +7,7 @@
7 @method renderTemplateData7 @method renderTemplateData
8 @param {Object} data Config data8 @param {Object} data Config data
9 @param {String} template The template filename9 @param {String} template The template filename
10 @param {String} filepath Path to render the template out to 10 @param {String} filepath Path to render the template out to
11*/11*/
12function renderTemplate(data, template, filepath) {12function renderTemplate(data, template, filepath) {
13 var fileData = fs.readFileSync(path.join('assets', template), 'utf8');13 var fileData = fs.readFileSync(path.join('assets', template), 'utf8');

Subscribers

People subscribed via source and target branches

to all changes: