Merge lp:~kim0/pyjuju/user-tutorial-and-FAQ into lp:pyjuju

Proposed by Ahmed Kamal
Status: Merged
Approved by: Gustavo Niemeyer
Approved revision: 206
Merged at revision: 220
Proposed branch: lp:~kim0/pyjuju/user-tutorial-and-FAQ
Merge into: lp:pyjuju
Diff against target: 396 lines (+375/-0)
3 files modified
docs/source/faq.rst (+49/-0)
docs/source/index.rst (+2/-0)
docs/source/user-tutorial.rst (+324/-0)
To merge this branch: bzr merge lp:~kim0/pyjuju/user-tutorial-and-FAQ
Reviewer Review Type Date Requested Status
Gustavo Niemeyer Approve
Review via email: mp+58861@code.launchpad.net

Description of the change

Added user level tutorial
Started a FAQ document

To post a comment you must log in.
Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :
Download full text (4.3 KiB)

Wow, this is *awesome* Ahmed. Thanks a lot!

I have several minor nits only due to the doc size, but it's indeed very
good overall.

Would you mind to check these out and let me know what you think?

[1]

+User Tutorial

Can you please lowercase the "Tutorial"? We had casing mixed up, and since the last doc
polishing I'm trying to have all documents standardizing around "Title case", so that
we have some consistency there.

[2]

10 + The name Ensemble is rooted in group communication systems and paxos, where

The Ensemble term actually comes from the meaning of the "ensemble" word itself:

"an assemblage of parts or details (as in a work of art) considered as forming a whole"

[3]

+ servers. Another way to look at it, is that Ensemble helps you manage an

s/,//

[4]

+ make those services communicate through a simple protocol. Users can then

s/communicate/coordinate their communication/

[5]

+ ready to be used in production. However adventerous users are encouraged to

s/However /However, /

s/adventerous/adventurous/

[6]

+ Ensemble itself is developed using python. However writing formulas for

s/However /However, /

[7]

37 + Ensemble can be done in any language. All Ensemble cares about is finding a
38 + set of executable files, which it will trigger appropriately. Hooks can be
39 + written in a variety of languages such as bash, python, perl, c++ and
40 + others

Might be better to end the paragraph in "appropriately.". It already said it
can be written in *any* language, so there's no need to give examples.

[8]

109 +Note the following, machine "0" has been started. This is usually the
110 +bootstrapping node and the first node to be started. The dns-name for the node

s/usually//, both affirmations are necessarily true.

[9]

+is printed. Also the ec2 instance-id is printed. Since no services are yet

s/ec2/EC2/

[10]

+This will connect to the environment, and start tailing logs

s/logs/logs./

[11]

+Deploying Service Units

s/S/s/ and s/U/u/, same as [1].

[12]

+We can see a new ec2 instance has now been spun up for mysql. Information for

s/ec2/EC2/

[13]

171 +We can see a new ec2 instance has now been spun up for mysql. Information for
172 +this instance is displayed as machine number 1. Mysql is now listed under
173 +services, it is apparent the mysql service unit has no relations, since it

Minor sentence refactoring:

  We can see a new ec2 instance has now been spun up for mysql. Information for
  this instance is displayed as machine number 1 and mysql is now listed under
  services. It is apparent that the mysql service unit has no relations, since it

[14]

174 +has not been connected to wordpress yet. Since this is the first mysql service
175 +unit, it is being referred to as mysql/0, subsequent service units would be

It would be nice to mention here, even if very briefly, the distinction between a
service and a service unit.

[15]

183 +Waiting a minute for all services to complete their configuration cycle and
184 +get properly started, then issuing a status command::

s/Waiting a/Let's wait for a/
s/then issuing/then issue/

[16]

+Adding Relation

=> "Adding a relation"

[17]...

Read more...

review: Approve
207. By Ahmed Kamal

Applying merge 58861 comments, text cleanups

Revision history for this message
Ahmed Kamal (kim0) wrote :

Thanks! I've applied your comments and pushed

208. By Ahmed Kamal

Adding project resources and contact info

209. By Ahmed Kamal

Aligning at two leading spaces

210. By Ahmed Kamal

Fixing typo, title underline too short

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'docs/source/faq.rst'
--- docs/source/faq.rst 1970-01-01 00:00:00 +0000
+++ docs/source/faq.rst 2011-05-05 13:46:31 +0000
@@ -0,0 +1,49 @@
1Frequently Asked Questions
2==========================
3
4Where does the name Ensemble come from?
5
6 The word ensemble could be defined as "an assemblage of parts or details
7 (as in a work of art) considered as forming a whole". Ensemble assembles
8 machines and software components and manages them as a whole, providing
9 service deployment and management, hence the name.
10
11Why is Ensemble useful?
12
13 Ensemble is a next generation service deployment and orchestration
14 framework. It has been likened to APT for the cloud. With Ensemble,
15 different authors are able to create service formulas independently, and
16 make those services coordinate their communication through a simple
17 protocol. Users can then take the product of different authors and very
18 comfortably deploy those services in an environment. The result is
19 multiple machines and components transparently collaborating towards
20 providing the requested service. Read more :doc:`about`
21
22When will it be ready for production?
23
24 As of Ubuntu Natty 11.04, Ensemble is a technology preview. It is not yet
25 ready to be used in production. However, adventurous users are encouraged to
26 evaluate it, study it, start writing formulas for it or start hacking on
27 Ensemble internals. The rough roadmap is to have Ensemble packaged for
28 Universe by 11.10 release and perhaps in main by 12.04
29
30What language is Ensemble developed in?
31
32 Ensemble itself is developed using python. However, writing formulas for
33 Ensemble can be done in any language. All Ensemble cares about is finding a
34 set of executable files, which it will trigger appropriately.
35
36How can I contact the Ensemble team?
37
38 User and formula author oriented resources
39 * Mailing list: https://lists.ubuntu.com/mailman/listinfo/Ubuntu-cloud
40 * IRC #ubuntu-cloud
41 Ensemble development
42 * Mailing list: https://lists.ubuntu.com/mailman/listinfo/Ensemble
43 * IRC #ubuntu-ensemble
44
45Where can I find out more about Ensemble?
46
47 * Project Site: https://launchpad.net/ensemble
48 * Ensemble Documentation: http://j.mp/ensemble-docs
49 * Work Items: http://people.canonical.com/~niemeyer/budapest.html
050
=== modified file 'docs/source/index.rst'
--- docs/source/index.rst 2011-05-05 09:41:11 +0000
+++ docs/source/index.rst 2011-05-05 13:46:31 +0000
@@ -10,7 +10,9 @@
10 :maxdepth: 210 :maxdepth: 2
1111
12 about12 about
13 faq
13 getting-started14 getting-started
15 user-tutorial
14 formula16 formula
15 hook-debugging17 hook-debugging
16 upgrades18 upgrades
1719
=== added file 'docs/source/user-tutorial.rst'
--- docs/source/user-tutorial.rst 1970-01-01 00:00:00 +0000
+++ docs/source/user-tutorial.rst 2011-05-05 13:46:31 +0000
@@ -0,0 +1,324 @@
1.. _user-tutorial:
2
3User tutorial
4=============
5
6Introduction
7------------
8
9This tutorial demonstrates basic features of Ensemble from a user perspective.
10An Ensemble user would typically be a devops or a sys-admin who is interested in
11automated deployment and management of servers and services.
12
13Bootstrapping
14-------------
15
16The first step for deploying an Ensemble system is to perform bootstrapping.
17Bootstrapping launches a utility instance that is used in all subsequent
18operations to launch and orchestrate other instances::
19
20 $ bin/ensemble bootstrap
21
22Note that while the command should display a message indicating it has finished
23successfully, that does not mean the bootstrapping instance is immediately
24ready for usage. Bootstrapping an instance can require a couple of minutes. To
25check on the status of the Ensemble deployment, we can use the status command::
26
27 $ bin/ensemble status
28
29If the bootstrapping node has not yet completed bootstrapping, the status
30command may either mention the environment is not yet ready, or may display a
31connection timeout such as::
32
33 INFO Connecting to environment.
34 ERROR Connection refused
35 ProviderError: Interaction with machine provider failed:
36 ConnectionTimeoutException('could not connect before timeout after 2
37 retries',)
38 ERROR ProviderError: Interaction with machine
39 provider failed: ConnectionTimeoutException('could not connect before timeout
40 after 2 retries',)
41
42This is simply an indication the environment needs more time to complete
43initialization. It is recommended you retry every minute. Once the environment
44has properly initialized, the status command should display::
45
46 machines:
47 0: {dns-name: ec2-50-16-61-111.compute-1.amazonaws.com, instance-id: i-2a702745}
48 services: {}
49
50Note the following, machine "0" has been started. This is the bootstrapping
51node and the first node to be started. The dns-name for the node is printed.
52Also the EC2 instance-id is printed. Since no services are yet deployed to the
53Ensemble system yet, the list of deployed services is empty
54
55Starting debug-log
56------------------
57
58While not a requirement, it is beneficial for the understanding of Ensemble to
59start a debug-log session. Ensemble's debug-log provides great insight into the
60execution of various hooks as they are triggered by various events. It is
61important to understand that debug-log shows events from a distributed
62environment (multiple-instances). This means that log lines will alternate
63between output from different instances. To start a debug-log session, from a
64secondary terminal issue::
65
66 $ bin/ensemble debug-log
67 INFO Connecting to environment.
68 INFO Enabling distributed debug log.
69 INFO Tailing logs - Ctrl-C to stop.
70
71This will connect to the environment, and start tailing logs.
72
73Deploying service units
74-----------------------
75
76Now that we have bootstrapped the Ensemble environment, and started the
77debug-log viewer, let's proceed by deploying a mysql service::
78
79 $ bin/ensemble deploy --repository=examples mysql
80 INFO Connecting to environment.
81 INFO Formula deployed as service: 'mysql'
82 INFO 'deploy' command finished successfully
83
84Checking the debug-log window, we can see the mysql service unit being
85downloaded and started::
86
87 Machine:1: ensemble.agents.machine DEBUG: Downloading formula
88 local:mysql-11...
89 Machine:1: ensemble.agents.machine INFO: Started service unit mysql/0
90
91It is important to note the different debug levels. DEBUG is used for very
92detailed logging messages, usually you should not care about reading such
93messages unless you are trying to debug (hence the name) a specific problem.
94INFO debugging level is used for slightly more important informational
95messages. In this case, these messages are generated as the mysql formula's
96hooks are being executed. Let's check the current status::
97
98 $ bin/ensemble status
99 machines:
100 0: {dns-name: ec2-50-16-61-111.compute-1.amazonaws.com, instance-id: i-2a702745}
101 1: {dns-name: ec2-50-16-117-185.compute-1.amazonaws.com, instance-id: i-227e294d}
102 services:
103 mysql:
104 formula: local:mysql-11
105 relations: {}
106 units:
107 mysql/0:
108 machine: 1
109 relations: {}
110 state: null
111
112We can see a new EC2 instance has now been spun up for mysql. Information for
113this instance is displayed as machine number 1 and mysql is now listed under
114services. It is apparent the mysql service unit has no relations, since it has
115not been connected to wordpress yet. Since this is the first mysql service
116unit, it is being referred to as mysql/0, subsequent service units would be
117named mysql/1 and so on.
118
119.. note::
120 An important distinction to make is the difference between a service
121 and a service unit. A service is a high level concept relating to an
122 end-user visible service such as mysql. The mysql service would be
123 composed of several mysql service units referred to as mysql/0, mysql/1
124 and so on.
125
126The mysql service state is listed as null since it's not ready yet.
127Downloading, installing, configuring and starting mysql can take some time.
128However we don't have to wait for it to configure, let's proceed deploying
129wordpress::
130
131 $ bin/ensemble deploy --repository=examples wordpress
132
133Let's wait for a minute for all services to complete their configuration cycle and
134get properly started, then issue a status command::
135
136 $ bin/ensemble status
137 machines:
138 0: {dns-name: ec2-50-16-61-111.compute-1.amazonaws.com, instance-id: i-2a702745}
139 1: {dns-name: ec2-50-16-117-185.compute-1.amazonaws.com, instance-id: i-227e294d}
140 2: {dns-name: ec2-184-72-156-54.compute-1.amazonaws.com, instance-id: i-9c7e29f3}
141 services:
142 mysql:
143 formula: local:mysql-11
144 relations: {}
145 units:
146 mysql/0:
147 machine: 1
148 relations: {}
149 state: started
150 wordpress:
151 formula: local:wordpress-29
152 relations: {}
153 units:
154 wordpress/0:
155 machine: 2
156 relations: {}
157 state: started
158
159mysql/0 as well as wordpress/0 are both now in the started state. Checking the
160debug-log would reveal wordpress has been started as well
161
162Adding a relation
163-----------------
164
165While mysql and wordpress service units have been started, they are still
166isolated from each other. An important concept for Ensemble is connecting
167various service units together to create a bigger ensemble! Adding a relation
168between service units causes hooks to trigger, in effect causing all service
169units to collaborate and work together to reach the desired end state. Adding a
170relation is extremely simple::
171
172 $ bin/ensemble add-relation wordpress mysql
173 INFO Connecting to environment.
174 INFO Added mysql relation to all service units.
175 INFO 'add_relation' command finished successfully
176
177Checking the Ensemble status we see that the db relation now exists with state
178up::
179
180 $ bin/ensemble status
181 machines:
182 0: {dns-name: ec2-50-16-61-111.compute-1.amazonaws.com, instance-id: i-2a702745}
183 1: {dns-name: ec2-50-16-117-185.compute-1.amazonaws.com, instance-id: i-227e294d}
184 2: {dns-name: ec2-184-72-156-54.compute-1.amazonaws.com, instance-id: i-9c7e29f3}
185 services:
186 mysql:
187 formula: local:mysql-11
188 relations: {db: wordpress}
189 units:
190 mysql/0:
191 machine: 1
192 relations:
193 db: {state: up}
194 state: started
195 wordpress:
196 formula: local:wordpress-29
197 relations: {db: mysql}
198 units:
199 wordpress/0:
200 machine: 2
201 relations:
202 db: {state: up}
203 state: started
204
205You can now point your browser at the public dns-name for instance 2 (running
206wordpress) to view the wordpress blog
207
208Tracing hook execution
209----------------------
210
211An Ensemble user should never have to trace the execution order of hooks,
212however if you are the kind of person who enjoys looking under the hood, this
213section is for you. Understanding hook order execution, the parallel nature of
214hook execution across instances, and how relation-set in a hook can trigger the
215execution of another hook is quite interesting and provides insight into
216Ensemble internals
217
218Here are a few important messages from the debug-log of this Ensemble run. The
219date field has been deliberately left in this log, in order to understand the
220parallel nature of hook execution.
221
222Things to consider while reading the log include:
223 * The time the log message was generated
224 * Which service unit is causing the log message (for example mysql/0)
225 * The message logging level. In this run DEBUG messages are generated by the
226 Ensemble core engine, while WARNING messages are generated by calling
227 ensemble-log from inside formulas (which you can read in the examples
228 folder)
229
230Let's view select debug-log messages which can help understand the execution
231order::
232
233 14:29:43,625 unit:mysql/0: hook.scheduler DEBUG: executing hook for wordpress/0:joined
234 14:29:43,626 unit:mysql/0: unit.relation.lifecycle DEBUG: Executing hook db-relation-joined
235 14:29:43,660 unit:wordpress/0: hook.scheduler DEBUG: executing hook for mysql/0:joined
236 14:29:43,660 unit:wordpress/0: unit.relation.lifecycle DEBUG: Executing hook db-relation-joined
237 14:29:43,661 unit:wordpress/0: unit.relation.lifecycle DEBUG: Executing hook db-relation-changed
238 14:29:43,789 unit:mysql/0: unit.hook.api WARNING: Creating new database and corresponding security settings
239 14:29:43,813 unit:wordpress/0: unit.hook.api WARNING: Retrieved hostname: ec2-184-72-156-54.compute-1.amazonaws.com
240 14:29:43,976 unit:mysql/0: unit.relation.lifecycle DEBUG: Executing hook db-relation-changed
241 14:29:43,997 unit:wordpress/0: hook.scheduler DEBUG: executing hook for mysql/0:modified
242 14:29:43,997 unit:wordpress/0: unit.relation.lifecycle DEBUG: Executing hook db-relation-changed
243 14:29:44,143 unit:wordpress/0: unit.hook.api WARNING: Retrieved hostname: ec2-184-72-156-54.compute-1.amazonaws.com
244 14:29:44,849 unit:wordpress/0: unit.hook.api WARNING: Creating appropriate upload paths and directories
245 14:29:44,992 unit:wordpress/0: unit.hook.api WARNING: Writing wordpress config file /etc/wordpress/config-ec2-184-72-156-54.compute-1.amazonaws.com.php
246 14:29:45,130 unit:wordpress/0: unit.hook.api WARNING: Writing apache config file /etc/apache2/sites-available/ec2-184-72-156-54.compute-1.amazonaws.com
247 14:29:45,301 unit:wordpress/0: unit.hook.api WARNING: Enabling apache modules: rewrite, vhost_alias
248 14:29:45,512 unit:wordpress/0: unit.hook.api WARNING: Enabling apache site: ec2-184-72-156-54.compute-1.amazonaws.com
249 14:29:45,688 unit:wordpress/0: unit.hook.api WARNING: Restarting apache2 service
250
251
252Scaling the ensemble
253--------------------
254
255Assuming your blog got really popular, is having high load and you decided to
256scale it up (it's a cloud deployment after all). Ensemble makes this magically
257easy. All what is needed is::
258
259 $ bin/ensemble add-unit wordpress
260 INFO Connecting to environment.
261 INFO Unit 'wordpress/1' added to service 'wordpress'
262 INFO 'add_unit' command finished successfully
263 $ bin/ensemble status
264 machines:
265 0: {dns-name: ec2-50-16-61-111.compute-1.amazonaws.com, instance-id: i-2a702745}
266 1: {dns-name: ec2-50-16-117-185.compute-1.amazonaws.com, instance-id: i-227e294d}
267 2: {dns-name: ec2-184-72-156-54.compute-1.amazonaws.com, instance-id: i-9c7e29f3}
268 3: {dns-name: ec2-50-16-156-106.compute-1.amazonaws.com, instance-id: i-ba6532d5}
269 services:
270 mysql:
271 formula: local:mysql-11
272 relations: {db: wordpress}
273 units:
274 mysql/0:
275 machine: 1
276 relations:
277 db: {state: up}
278 state: started
279 wordpress:
280 formula: local:wordpress-29
281 relations: {db: mysql}
282 units:
283 wordpress/0:
284 machine: 2
285 relations:
286 db: {state: up}
287 state: started
288 wordpress/1:
289 machine: 3
290 relations:
291 db: {state: up}
292 state: started
293
294
295The add-unit command starts a new wordpress instance (wordpress/1), which then
296joins the relation with the already existing mysql/0 instance. mysql/0 notices
297the database required has already been created and thus decides all needed
298configuration has already been done. On the other hand wordpress/1 reads
299service settings from mysql/0 and starts configuring itself and joining the
300ensemble. Let's review a short version of debug-log for adding wordpress/1::
301
302 14:36:19,755 unit:mysql/0: hook.scheduler DEBUG: executing hook for wordpress/1:joined
303 14:36:19,755 unit:mysql/0: unit.relation.lifecycle DEBUG: Executing hook db-relation-joined
304 14:36:19,810 unit:wordpress/1: hook.scheduler DEBUG: executing hook for mysql/0:joined
305 14:36:19,811 unit:wordpress/1: unit.relation.lifecycle DEBUG: Executing hook db-relation-joined
306 14:36:19,811 unit:wordpress/1: unit.relation.lifecycle DEBUG: Executing hook db-relation-changed
307 14:36:19,918 unit:mysql/0: unit.hook.api WARNING: Database already exists, exiting
308 14:36:19,938 unit:mysql/0: unit.relation.lifecycle DEBUG: Executing hook db-relation-changed
309 14:36:19,990 unit:wordpress/1: unit.hook.api WARNING: Retrieved hostname: ec2-50-16-156-106.compute-1.amazonaws.com
310 14:36:20,757 unit:wordpress/1: unit.hook.api WARNING: Creating appropriate upload paths and directories
311 14:36:20,916 unit:wordpress/1: unit.hook.api WARNING: Writing wordpress config file /etc/wordpress/config-ec2-50-16-156-106.compute-1.amazonaws.com.php
312 14:36:21,088 unit:wordpress/1: unit.hook.api WARNING: Writing apache config file /etc/apache2/sites-available/ec2-50-16-156-106.compute-1.amazonaws.com
313 14:36:21,236 unit:wordpress/1: unit.hook.api WARNING: Enabling apache modules: rewrite, vhost_alias
314 14:36:21,476 unit:wordpress/1: unit.hook.api WARNING: Enabling apache site: ec2-50-16-156-106.compute-1.amazonaws.com
315 14:36:21,682 unit:wordpress/1: unit.hook.api WARNING: Restarting apache2 service
316
317Destroying the environment
318--------------------------
319
320Once you are done with an Ensemble deployment, you need to terminate all
321running instances in order to stop paying for them. The shutdown command helps
322terminate all running instances::
323
324 $ bin/ensemble shutdown

Subscribers

People subscribed via source and target branches

to status/vote changes: