1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
|
<?xml version='1.0'?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
]>
<chapter id="genome-Cookbook">
<title>Cookbook</title>
<para>
This chapter contains many useful &PRODUCT; recipes. While a solid understanding of the
toolset is always preferred this chapter is meant to be the user's reference manual.
</para>
<section id="genome-hypervisor-setup">
<title>Setting up an environment to host virtual machines</title>
<para>
Virtualization is by no means a requirement to make use of
the &PRODUCT; tooling, though it is the more common than
"bare metal" provisioning.
</para>
<para>
The machine used to host virtual machines is called the
Cloud Appliance. As the name suggests, there can be
one-to-many physical machines. The first
goal of this machine is to provide and environment to
host virtual machines and for that reason are
<emphasis>always</emphasis> provisioned on "bare
metal". The second is to provide an effective way to
manage resources amongst underutilized commodity
hardware.
</para>
<para>
Since virtualization plays such a key role in the
&PRODUCT; environment these machines amongst the first
that users of the &PRODUCT; tooling desire to get up
and running quickly.
</para>
<note>
<title>Note</title>
<para>
One of the main goals of the current
Cloud machine tooling is to
<emphasis>Do the simplest thing that
could possibly work</emphasis>.
This functionality, implemented through
<ulink
url="https://fedorahosted.org/func">Func</ulink>
modules, will most likely be entirely
replaced with <ulink
url="http://ovirt.org/">ovirt</ulink>.
</para>
</note>
<section id="cloud-appliance-setup">
<title>Using genome-replace-self</title>
<para>
The first step is to install the genome-replace-self RPM. You can
do this by running one of the following commands:
<screen>
rpm -Uvh --force http://ftp.redhat.com/pub/redhat/genome/yum/Fedora-9-genome-noarch/genome-replace-self-1.0.0-2.fc9.noarch.rpm
</screen>
If you want to install the RPM from your local Genome server,
the format would be:
<screen>
rpm -Uvh --force http://$GENOME_MACHINE/cobbler/repo_mirror/Fedora-9-genome-noarch/genome-replace-self-1.0.0-2.fc9.noarch.rpm
</screen>
</para>
<para>
Cloud Appliances use <link
linkend="genome-replace-self">genome-replace-self</link>
to get up and running quickly. The key to
using
<application>genome-replace-self</application>
to provision a Cloud Appliance is to:
<itemizedlist>
<listitem>
<para>
Use a <emphasis>Cloud</emphasis> profile.
</para>
</listitem>
<listitem>
<para>
Set the
<emphasis>-m</emphasis>
(metadata) flag
appropriately.
</para>
<para>
The value for this flag varies depending if it is
the <emphasis>certmaster</emphasis> or
a <emphasis>minion</emphasis> in
<application>func</application> parlance.
</para>
<para>
For the master set <emphasis>-m</emphasis> to
<emphasis>certmaster=localhost</emphasis>
</para>
<para>
For the minion set
<emphasis>-m</emphasis>
to
<emphasis>certmaster=[Any
previously
created Cloud
master]</emphasis>
</para>
</listitem>
</itemizedlist>
</para>
</section>
</section>
<section id="genome-RepoMachineBootstrapping">
<title>Creating your own &PRODUCT; Repo Appliance</title>
<para>
The Repo Appliance provisioning story is fairly straight forward:
<itemizedlist>
<listitem>
<para>install the &REPORPM; (either via kickstart or manually)</para>
</listitem>
<listitem>
<para>Replicate
<application>cobbler</application>
to pull down the bits and
kickstarts</para>
</listitem>
<listitem>
<para>Syncronize the
<application>git</application>
repositories from
another Repo Appliance.</para>
</listitem>
<listitem>
<para>
Define access controls
</para>
</listitem>
</itemizedlist>
</para>
<section>
<title>Installing the &REPORPM;</title>
<para>
There are several options on how to go about
this step. If another Repo Appliance is already
available
<application>genome-replace-self</application>
or <application>koan</application> based
options are generally preferred since they require
fewer manual steps.
</para>
<section>
<title>Creating a virtual Repo Appliance with koan</title>
<screen>
# See what profiles are available
koan -s [remote Repo Appliance] --list=profiles
# If choosing a virtual machine
koan -s [remote Repo Appliance] --virt --virt-name=[Any name] --profile=[Profile from first step] --virt-path=[Usually a Volume Group or path to a file]
</screen>
</section>
<section>
<title>Creating a baremetal Repo Appliance with genome-replace-self</title>
<para>
The only step needed for this is to use <link
linkend="genome-replace-self">genome-replace-self</link>
and pass in a Repo profile.
</para>
</section>
<section>
<title>Creating a Repo Appliance out of a machine that already has an Operating System</title>
<para>
If installing this on a
machine that already has an operating system (OS)
installed simply <userinput>yum install genome-repo</userinput>.
</para>
<para>
In case the &REPORPM; is not available in the
stock <application>yum</application>
repositories for your OS you can grab the RPMs
from any other &PRODUCT; Repo Appliance at
http://[hostname]/cobbler/repo_mirror/[distro]-genome-noarch.
</para>
<para>
Whenever installing the &REPORPM;
manually there is one other step that
needs to happen to properly configure a
Repo Appliance.
<screen>
/sbin/service genome-repo-bootstrap start
</screen>
</para>
<note>
<title>Note</title>
<para>
This step is designed to work
"offline" since all the
external dependencies are
pulled down via the &REPORPM;.
That being said there are
external factors than can cause
it to fail. If you suspect a
Repo Appliance is not configured
correctly it is always safe to
run this command multiple times
as
<application>puppet</application>
will only perform outstanding
tasks.
</para>
</note>
</section>
</section>
<section>
<title>Replicate cobbler data</title>
<para>
The simplest way to do this is to use
<application>cobbler</application>'s replicate
functionality.
<screen>
cobbler replicate --master=[remote Genome Repo machine] --full-data-sync
</screen>
For more advanced usage see the
<application>cobbler</application> manpage.
<important>
<title>Important</title>
<para>
Currently the use of
<userinput>cobbler
replicate</userinput>
requires the user to know the
root password on the master
cobbler server (the remote Repo
machine). This is less than
desirable but for now the
default password is
<emphasis>&GENOMEPASSWORD;</emphasis>.
</para>
</important>
<note>
<title>Note</title>
<para>
Technically it is also possible
to configure
<application>cobbler</application>
by hand. This obviously
requires a more in depth
understanding of
<application>cobbler</application>
and is outside the scope of
this document.
</para>
</note>
</para>
</section>
<section>
<title>Syncronize the git repositories</title>
<para>
Since this is a newly provisioned Repo Appliance
the fastest way to get up and running is to
run:
<screen>
# "reset --hard" to all the git repositories on a remote Repo
genome-sync start quick --repo=[remote Repo Appliance]
# Push all the repos where they need to go on the new Repo Appliance
genome-sync save
</screen>
</para>
<important>
<title>Important</title>
<para>
If any <emphasis>new</emphasis> puppet
modules are saved the
<application>puppetmaster</application>
will have to be restarted for them to be
available.
</para>
</important>
</section>
<section>
<title>Define access controls</title>
<para>
All machines in the &PRODUCT; environment have
a default root password set as detailed in
<link linkend="genome-LoggingIn">the
appendix</link>. By default Repo
Appliances have a local user named &GENOMEUSER;
who owns all content under
<filename>/pub/git</filename>. Out of the box
there is no password set and users of Repo
Appliances should feel free to use whatever
method of authentication they choose.
</para>
<para>
Typical methods of authentication are:
<itemizedlist>
<listitem>
<para>
Setting a password
</para>
</listitem>
<listitem>
<para>
Using SSH public key authentication
</para>
</listitem>
</itemizedlist>
</para>
<note>
<title>Note</title>
<para>
There is a good chance &PRODUCT; will
make use of <ulink
url="http://freeipa.org">FreeIPA</ulink>
someday.
</para>
</note>
</section>
</section>
<section>
<title>Cleaning up SSL certificates</title>
<para>
Due to the volatile nature of &PRODUCT; machines there
occasionally comes a need to clean up SSL certificates.
To clean up all Puppet certs you can simply stop the
<application>puppetmaster</application> (in the case of
a Repo Application) and <application>puppetd</application>
services and then remove
<filename>/var/lib/puppet/ssl</filename>. When you
start the services back up the certificates will be
created anew.
</para>
<para>
Sometimes the Puppetmaster will have a cert that
corresponds to a machine previously provisioned with
the same hostname. Our bootstrap process cleans this
up automatically but it's not hard to get into a state
where it will need to be cleaned manually on the
Puppetmaster side. Luckily this is easy to do. The
error from Puppet even hints at how to do it. Login to
your Repo Appliance as the local user (usually
<emphasis>genome</emphasis>) and run <userinput>sudo
/usr/sbin/puppetca --clean [your
hostname]</userinput>
</para>
<important>
<title>Important</title>
<para>
<application>sudo</application> access to
<application>puppetca</application> has been
given to the local &PRODUCT; user.
</para>
</important>
</section>
<section id="genome-NoKoanBootstrap">
<title>Bootstrapping a machine that already has an OS</title>
<important>
<title>Important</title>
<para>
This particular recipe should be
considered advanced. There are plenty of ways to make a custom system
incompatible with the &PRODUCT; tooling. Be sure you are comfortable with how
&FIRSTBOOTFILE; works.
</para>
</important>
<para>
In some cases you might not want to reinstall
the OS on a system in the &PRODUCT;
environment. This happens mostly for laptops
where a developer simply wants a build
environment so they can work "off the grid".
</para>
<para>
For this recipe the user simply needs to pass
the <emphasis>--config-only</emphasis> option
to <application>genome-bootstrap</application>
to create the needed server-side configuration.
Once that is done it's just a matter of
installing the
<application>genome-firstboot</application>
RPM and editing
<filename>/etc/sysconfig/genome-firstboot</filename>.
Here's an example config file:
<screen>
RUN_BOOTSTRAP=YES
export GENOME_REPO=genome-staging-repo.usersys.redhat.com
export FQDN=arch-repo.usersys.redhat.com
</screen>
</para>
<note>
<title>Note</title>
<para>
It's always best to grab the RPMs from
the &PRODUCT; Repo you are going to
use. That way you can be certain you
are using a compatible version.
</para>
</note>
</section>
<section id="genome-AddMachineType">
<title>Adding a new machine type</title>
<para>
There are several tools and config files that need to
know what types of machines are available for
provisioning on a particular <link
linkend="genome-appliance">Repo
machine</link>. To simplify this process
&PRODUCT; includes a DSL (Domain Specific Language) for
describing the machines available.
</para>
<para>
At a very high level the only thing that needs to be
done is edit
<filename>/etc/genome/machine_types.rb</filename> on a
Repo Appliance. The comments are the best documentation
for the details. The trick is that this file is
typically <link
linkend="genome-repo-machine-customization">controlled
by puppet</link>.
</para>
<para>
<link linkend="genome-sync">genome-sync</link> is a
great way to handle moving custom machine types from
one Repo Appliance to another.
</para>
</section>
<section id="genome-ChangingAMachineParameter">
<title>Changing a machine's parameters</title>
<para>
It's convenient to be able to change bootstrapped
parameters. One typical use case is if you would like to
point your machine to a different puppet master.
</para>
<para>
To do this simplify access the
<application>genomed</application> running on the
&PRODUCT; Repo that your machine is subscribed to and
update the yaml file. Once the yaml has been updated
you probably want to manually run Puppet
(<userinput>puppetd --test</userinput>) to update the
machine's configuration.
</para>
</section>
<section id="genome-PuppetRebasing">
<title>Change the puppet master of any given machine type</title>
<para>
<orderedlist numeration="arabic">
<listitem>
<para>
Browse to
http://[repo]/genome/nodes/[hostname].html
and update the yaml file.
</para>
</listitem>
<listitem>
<para>
Edit the &PUPPETCONFFILE; and
change any instances of the
current puppet master hostname
to the hostname of the new
puppet master
</para>
</listitem>
<listitem>
<para>
Make sure there exists a machine configuration for this host on the other repo
machine. If not simply create a new one using
<application>genomed</application> or by using <userinput>genome-bootstrap
--config-only</userinput>.
</para>
</listitem>
<listitem>
<para>
Remove the &PUPPET_SSL_DIR;
directory, this will be
recreated with a valid set of
certificates and keys
</para>
</listitem>
<listitem>
<para>
Run <command>puppetd --test</command> to make sure
everything worked. If all goes well,
start the puppet client and you're
done.
</para>
</listitem>
</orderedlist>
</para>
</section>
<section id="genome-GitRecipes">
<title>Git Recipes</title>
<para>
This recipe involves a situation where you have 4
commits, with 1,2, and 4 being related and commit 3
just in the middle. Ideally, before you submit this,
you would like to combine 1,2, and 4 into a single
commit and then have commit 3 and a second, isolated
commit.
</para>
<para>
Run the following to prime you repository with this
scenario:
</para>
<screen>
cd ~
mkdir git-test
cd git-test
git init
touch a.txt
git add a.txt
git-commit -m "Adding one file"
touch b.txt
git add b.txt
git-commit -m "Adding another file"
touch different.txt
git add different.txt
git-commit -m "Commiting something entirely different"
touch c.txt
git add c.txt
git-commit -m "Adding yet another file"
</screen>
<para>
Correcting the problem:
<orderedlist numeration="arabic">
<listitem>
<para>
Look at the log history and get
the id of the initial commit
revision:
<userinput>git log</userinput>
</para>
</listitem>
<listitem>
<para>
Start a working branch and check it out
to serve as the cleanup branch,
starting at the initial commit:
<userinput>
git checkout -b cleanup <varname>[REVISION]</varname>
</userinput>
</para>
</listitem>
<listitem>
<para>
Confirm you are now working on the new branch:
<userinput>git status</userinput>
</para>
</listitem>
<listitem>
<para>
Confirm the log history only contains the initial commit:
<userinput>git log</userinput>
</para>
</listitem>
<listitem>
<para>
Now, since we want to add two
more things to this commit and
re-commit it. First, you need
to get the commit revisions
from the master branch:
<userinput>git log master</userinput>
</para>
</listitem>
<listitem>
<para>
Now, you need to cherry pick
commits 2 and 4 without
commiting:
<screen>
git-cherry-pick -n <varname>[REVISION 2]</varname>
git-cherry-pick -n <varname>[REVISION 4]</varname>
</screen>
</para>
</listitem>
<listitem>
<para>
Now you need to revise the current
commit comment to include what was done
in revisions 2 and 4
<userinput>git-commit --revise</userinput>
</para>
</listitem>
<listitem>
<para>
At this point, you have combined 1,2,
and 4 into a single commit. The last
step is to cherry pick and commit
revision 3:
<userinput>git-cherry-pick <varname>[REVISION 3]</varname></userinput>
</para>
</listitem>
<listitem>
<para>
Now you can push the changes from this
branch to the desired public
repository.
</para>
</listitem>
</orderedlist>
</para>
</section>
</chapter>
|