~jimbaker/pyjuju/ssh-known_hosts

« back to all changes in this revision

Viewing changes to docs/source/user-tutorial.rst

  • Committer: Gustavo Niemeyer
  • Date: 2011-09-16 00:37:59 UTC
  • mfrom: (348.1.13 the-big-renaming)
  • Revision ID: gustavo@niemeyer.net-20110916003759-bx3vsznroj4gv7w7
Merging the-big-renaming branch! Say hello to juju!

This is a massive change renaming and fixing several things
on the way. Unfortunately my day is finishing and I didn't
manage to get 100% of the tests passing, but there's very
few things broken right now, and I don't want to keep such
a massive change flying around.

We'll sort any details out tomorrow.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
Introduction
7
7
------------
8
8
 
9
 
This tutorial demonstrates basic features of Ensemble from a user perspective.
10
 
An Ensemble user would typically be a devops or a sys-admin who is interested in
 
9
This tutorial demonstrates basic features of juju from a user perspective.
 
10
An juju user would typically be a devops or a sys-admin who is interested in
11
11
automated deployment and management of servers and services.
12
12
 
13
13
Bootstrapping
14
14
-------------
15
15
 
16
 
The first step for deploying an Ensemble system is to perform bootstrapping.
 
16
The first step for deploying an juju system is to perform bootstrapping.
17
17
Bootstrapping launches a utility instance that is used in all subsequent
18
18
operations to launch and orchestrate other instances::
19
19
 
20
 
  $ ensemble bootstrap
 
20
  $ juju bootstrap
21
21
 
22
22
Note that while the command should display a message indicating it has finished
23
23
successfully, that does not mean the bootstrapping instance is immediately
24
24
ready for usage. Bootstrapping an instance can require a couple of minutes. To
25
 
check on the status of the Ensemble deployment, we can use the status command::
 
25
check on the status of the juju deployment, we can use the status command::
26
26
 
27
 
  $ ensemble status
 
27
  $ juju status
28
28
 
29
29
If the bootstrapping node has not yet completed bootstrapping, the status
30
30
command may either mention the environment is not yet ready, or may display a
50
50
Note the following, machine "0" has been started. This is the bootstrapping
51
51
node and the first node to be started. The dns-name for the node is printed.
52
52
Also the EC2 instance-id is printed. Since no services are yet deployed to the
53
 
Ensemble system yet, the list of deployed services is empty
 
53
juju system yet, the list of deployed services is empty
54
54
 
55
55
Starting debug-log
56
56
------------------
57
57
 
58
 
While not a requirement, it is beneficial for the understanding of Ensemble to
59
 
start a debug-log session. Ensemble's debug-log provides great insight into the
 
58
While not a requirement, it is beneficial for the understanding of juju to
 
59
start a debug-log session. juju's debug-log provides great insight into the
60
60
execution of various hooks as they are triggered by various events. It is
61
61
important to understand that debug-log shows events from a distributed
62
62
environment (multiple-instances). This means that log lines will alternate
63
63
between output from different instances. To start a debug-log session, from a
64
64
secondary terminal issue::
65
65
 
66
 
  $ ensemble debug-log
 
66
  $ juju debug-log
67
67
  INFO Connecting to environment.
68
68
  INFO Enabling distributed debug log.
69
69
  INFO Tailing logs - Ctrl-C to stop.
73
73
Deploying service units
74
74
-----------------------
75
75
 
76
 
Now that we have bootstrapped the Ensemble environment, and started the
 
76
Now that we have bootstrapped the juju environment, and started the
77
77
debug-log viewer, let's proceed by deploying a mysql service::
78
78
 
79
 
  $ ensemble deploy --repository=examples mysql
 
79
  $ juju deploy --repository=examples mysql
80
80
  INFO Connecting to environment.
81
 
  INFO Formula deployed as service: 'mysql'
 
81
  INFO Charm deployed as service: 'mysql'
82
82
  INFO 'deploy' command finished successfully
83
83
 
84
84
Checking the debug-log window, we can see the mysql service unit being
85
85
downloaded and started::
86
86
 
87
 
  Machine:1: ensemble.agents.machine DEBUG: Downloading formula
 
87
  Machine:1: juju.agents.machine DEBUG: Downloading charm
88
88
  local:mysql-11...
89
 
  Machine:1: ensemble.agents.machine INFO: Started service unit mysql/0
 
89
  Machine:1: juju.agents.machine INFO: Started service unit mysql/0
90
90
 
91
91
It is important to note the different debug levels. DEBUG is used for very
92
92
detailed logging messages, usually you should not care about reading such
93
93
messages unless you are trying to debug (hence the name) a specific problem.
94
94
INFO debugging level is used for slightly more important informational
95
 
messages. In this case, these messages are generated as the mysql formula's
 
95
messages. In this case, these messages are generated as the mysql charm's
96
96
hooks are being executed. Let's check the current status::
97
97
 
98
 
  $ ensemble status
 
98
  $ juju status
99
99
  machines:
100
100
    0: {dns-name: ec2-50-16-61-111.compute-1.amazonaws.com, instance-id: i-2a702745}
101
101
    1: {dns-name: ec2-50-16-117-185.compute-1.amazonaws.com, instance-id: i-227e294d}
102
102
  services:
103
103
    mysql:
104
 
      formula: local:mysql-11
 
104
      charm: local:mysql-11
105
105
      relations: {}
106
106
      units:
107
107
        mysql/0:
128
128
However we don't have to wait for it to configure, let's proceed deploying
129
129
wordpress::
130
130
 
131
 
  $ ensemble deploy --repository=examples wordpress
 
131
  $ juju deploy --repository=examples wordpress
132
132
 
133
133
Let's wait for a minute for all services to complete their configuration cycle and
134
134
get properly started, then issue a status command::
135
135
 
136
 
  $ ensemble status
 
136
  $ juju status
137
137
  machines:
138
138
    0: {dns-name: ec2-50-16-61-111.compute-1.amazonaws.com, instance-id: i-2a702745}
139
139
    1: {dns-name: ec2-50-16-117-185.compute-1.amazonaws.com, instance-id: i-227e294d}
140
140
    2: {dns-name: ec2-184-72-156-54.compute-1.amazonaws.com, instance-id: i-9c7e29f3}
141
141
  services:
142
142
    mysql:
143
 
      formula: local:mysql-11
 
143
      charm: local:mysql-11
144
144
      relations: {}
145
145
      units:
146
146
        mysql/0:
148
148
          relations: {}
149
149
          state: started
150
150
    wordpress:
151
 
      formula: local:wordpress-29
 
151
      charm: local:wordpress-29
152
152
      relations: {}
153
153
      units:
154
154
        wordpress/0:
163
163
-----------------
164
164
 
165
165
While mysql and wordpress service units have been started, they are still
166
 
isolated from each other. An important concept for Ensemble is connecting
167
 
various service units together to create a bigger ensemble! Adding a relation
 
166
isolated from each other. An important concept for juju is connecting
 
167
various service units together to create a bigger juju! Adding a relation
168
168
between service units causes hooks to trigger, in effect causing all service
169
169
units to collaborate and work together to reach the desired end state. Adding a
170
170
relation is extremely simple::
171
171
 
172
 
  $ ensemble add-relation wordpress mysql
 
172
  $ juju add-relation wordpress mysql
173
173
  INFO Connecting to environment.
174
174
  INFO Added mysql relation to all service units.
175
175
  INFO 'add_relation' command finished successfully
176
176
 
177
 
Checking the Ensemble status we see that the db relation now exists with state
 
177
Checking the juju status we see that the db relation now exists with state
178
178
up::
179
179
 
180
 
  $ ensemble status
 
180
  $ juju status
181
181
  machines:
182
182
    0: {dns-name: ec2-50-16-61-111.compute-1.amazonaws.com, instance-id: i-2a702745}
183
183
    1: {dns-name: ec2-50-16-117-185.compute-1.amazonaws.com, instance-id: i-227e294d}
184
184
    2: {dns-name: ec2-184-72-156-54.compute-1.amazonaws.com, instance-id: i-9c7e29f3}
185
185
  services:
186
186
    mysql:
187
 
      formula: local:mysql-11
 
187
      charm: local:mysql-11
188
188
      relations: {db: wordpress}
189
189
      units:
190
190
        mysql/0:
193
193
            db: {state: up}
194
194
          state: started
195
195
    wordpress:
196
 
      formula: local:wordpress-29
 
196
      charm: local:wordpress-29
197
197
      relations: {db: mysql}
198
198
      units:
199
199
        wordpress/0:
208
208
Tracing hook execution
209
209
----------------------
210
210
 
211
 
An Ensemble user should never have to trace the execution order of hooks,
 
211
An juju user should never have to trace the execution order of hooks,
212
212
however if you are the kind of person who enjoys looking under the hood, this
213
213
section is for you. Understanding hook order execution, the parallel nature of
214
214
hook execution across instances, and how relation-set in a hook can trigger the
215
215
execution of another hook is quite interesting and provides insight into
216
 
Ensemble internals
 
216
juju internals
217
217
 
218
 
Here are a few important messages from the debug-log of this Ensemble run.  The
 
218
Here are a few important messages from the debug-log of this juju run.  The
219
219
date field has been deliberately left in this log, in order to understand the
220
220
parallel nature of hook execution.
221
221
 
223
223
 * The time the log message was generated
224
224
 * Which service unit is causing the log message (for example mysql/0)
225
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
 
226
   juju core engine, while WARNING messages are generated by calling
 
227
   juju-log from inside charms (which you can read in the examples
228
228
   folder)
229
229
 
230
230
Let's view select debug-log messages which can help understand the execution
249
249
  14:29:45,688 unit:wordpress/0: unit.hook.api WARNING: Restarting apache2 service
250
250
 
251
251
 
252
 
Scaling the ensemble
 
252
Scaling the juju
253
253
--------------------
254
254
 
255
255
Assuming your blog got really popular, is having high load and you decided to
256
 
scale it up (it's a cloud deployment after all). Ensemble makes this magically
 
256
scale it up (it's a cloud deployment after all). juju makes this magically
257
257
easy. All what is needed is::
258
258
 
259
 
  $ ensemble add-unit wordpress
 
259
  $ juju add-unit wordpress
260
260
  INFO Connecting to environment.
261
261
  INFO Unit 'wordpress/1' added to service 'wordpress'
262
262
  INFO 'add_unit' command finished successfully
263
 
  $ ensemble status
 
263
  $ juju status
264
264
  machines:
265
265
    0: {dns-name: ec2-50-16-61-111.compute-1.amazonaws.com, instance-id: i-2a702745}
266
266
    1: {dns-name: ec2-50-16-117-185.compute-1.amazonaws.com, instance-id: i-227e294d}
268
268
    3: {dns-name: ec2-50-16-156-106.compute-1.amazonaws.com, instance-id: i-ba6532d5}
269
269
  services:
270
270
    mysql:
271
 
      formula: local:mysql-11
 
271
      charm: local:mysql-11
272
272
      relations: {db: wordpress}
273
273
      units:
274
274
        mysql/0:
277
277
            db: {state: up}
278
278
          state: started
279
279
    wordpress:
280
 
      formula: local:wordpress-29
 
280
      charm: local:wordpress-29
281
281
      relations: {db: mysql}
282
282
      units:
283
283
        wordpress/0:
297
297
the database required has already been created and thus decides all needed
298
298
configuration has already been done. On the other hand wordpress/1 reads
299
299
service settings from mysql/0 and starts configuring itself and joining the
300
 
ensemble. Let's review a short version of debug-log for adding wordpress/1::
 
300
juju. Let's review a short version of debug-log for adding wordpress/1::
301
301
 
302
302
  14:36:19,755 unit:mysql/0: hook.scheduler DEBUG: executing hook for wordpress/1:joined
303
303
  14:36:19,755 unit:mysql/0: unit.relation.lifecycle DEBUG: Executing hook db-relation-joined
317
317
Destroying the environment
318
318
--------------------------
319
319
 
320
 
Once you are done with an Ensemble deployment, you need to terminate
 
320
Once you are done with an juju deployment, you need to terminate
321
321
all running instances in order to stop paying for them. The
322
322
destroy-environment command will terminate all running instances in an
323
323
environment::
324
324
 
325
 
  $ ensemble destroy-environment
 
325
  $ juju destroy-environment
326
326
 
327
 
Ensemble will ask for user confirmation before proceeding as this
 
327
juju will ask for user confirmation before proceeding as this
328
328
command will destroy service data in the environment as well.