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
|
.. -*- mode: rst -*-
.. _quickstart-centos:
.. _EPEL: http://fedoraproject.org/wiki/EPEL
=====================
Quickstart for CentOS
=====================
This is a complete getting started guide for CentOS. With this document you should be able to install a Bcfg2 server, a Bcfg2 client, and change the ``/etc/motd`` file on the client.
Install Bcfg2 From RPM
======================
The fastest way to get Bcfg2 onto your system is to get a RPM someone else has already made. We'll be using the ones that are distributed through EPEL_, but depending on your aversion to risk you could download an RPM from other places as well. See :ref:`using_bcfg2-with-centos` for information about building Bcfg2 from source and making your own packages.
Using EPEL
----------
* Make sure EPEL is a valid repository on your server. The `instructions <http://fedoraproject.org/wiki/EPEL/FAQ#howtouse>`_ on how to do this basically say::
# su -c 'rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm'
...lot's of output...
* Install the bcfg2-server and bcfg2 RPMs ::
$ sudo yum install bcfg2-server bcfg2
Your system should now have the necessary software to use Bcfg2. The next step is to set up your Bcfg2 :term:`repository`.
Initialize your repository
==========================
Now that you're done with the install, you need to initialize your
repository and setup your ``/etc/bcfg2.conf``. ``bcfg2-admin init``
is a tool which allows you to automate this::
[root@centos ~]# bcfg2-admin init
Store bcfg2 configuration in [/etc/bcfg2.conf]:
Location of bcfg2 repository [/var/lib/bcfg2]:
Input password used for communication verification (without echoing; leave blank for a random):
What is the server's hostname: [centos]
Input the server location [https://centos:6789]:
Input base Operating System for clients:
1: Redhat/Fedora/RHEL/RHAS/Centos
2: SUSE/SLES
3: Mandrake
4: Debian
5: Ubuntu
6: Gentoo
7: FreeBSD
: 1
Generating a 2048 bit RSA private key
.........................+++
..................+++
writing new private key to '/etc/bcfg2.key'
-----
Signature ok
subject=/C=US=ST=Illinois/L=Argonne/CN=centos
Getting Private key
Repository created successfuly in /var/lib/bcfg2
Change responses as necessary.
Start the server
================
You are now ready to start your bcfg2 server for the first time::
$ sudo /sbin/service bcfg2-server start
To verify that everything started ok, look for the running daemon and check the logs::
$ sudo /sbin/service bcfg2-server status
$ sudo tail /var/log/messages
Mar 29 12:42:26 centos bcfg2-server[5093]: service available at https://centos:6789
Mar 29 12:42:26 centos bcfg2-server[5093]: serving bcfg2-server at https://centos:6789
Mar 29 12:42:26 centos bcfg2-server[5093]: serve_forever() [start]
Mar 29 12:42:41 centos bcfg2-server[5093]: Handled 16 events in 0.007s
Run bcfg2 to be sure you are able to communicate with the server::
[root@centos ~]# bcfg2 -vqn
No ca is specified. Cannot authenticate the server with SSL.
No ca is specified. Cannot authenticate the server with SSL.
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Excluding Packages in global exclude list
Finished
Loaded tool drivers:
Action Chkconfig POSIX YUMng
Phase: initial
Correct entries: 0
Incorrect entries: 0
Total managed entries: 0
Unmanaged entries: 208
Phase: final
Correct entries: 0
Incorrect entries: 0
Total managed entries: 0
Unmanaged entries: 208
No ca is specified. Cannot authenticate the server with SSL.
The ca message is just a warning, meaning that the client does not
have sufficient information to verify that it is talking to the
correct server. This can be fixed by distributing the ca certificate
from the server to all clients. By default, this file is available in
``/etc/bcfg2.crt`` on the server. Copy this file to the client (with a
bundle) and add the ca option to ``bcfg2.conf`` pointing at the file,
and the client will be able to verify it is talking to the correct server
upon connection::
[root@centos ~]# cat /etc/bcfg2.conf
[communication]
protocol = xmlrpc/ssl
password = N41lMNeW
ca = /etc/bcfg2.crt
[components]
bcfg2 = https://centos:6789
Now if you run the client, no more warning::
[root@centos ~]# bcfg2 -vqn
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Excluding Packages in global exclude list
Finished
Loaded tool drivers:
Action Chkconfig POSIX YUMng
Phase: initial
Correct entries: 0
Incorrect entries: 0
Total managed entries: 0
Unmanaged entries: 208
Phase: final
Correct entries: 0
Incorrect entries: 0
Total managed entries: 0
Unmanaged entries: 208
Bring your first machine under Bcfg2 control
--------------------------------------------
Now it is time to get your first machine's configuration into your
Bcfg2 repository. Let's start with the server itself.
Setup the `Packages`_ plugin
++++++++++++++++++++++++++++
.. _Packages: http://trac.mcs.anl.gov/projects/bcfg2/wiki/Plugins/Packages
First, replace **Pkgmgr** with **Packages** in the plugins
line of ``bcfg2.conf``. Then create Packages layout (as per
:ref:`packages-exampleusage`) in ``/var/lib/bcfg2``
.. note:: I am using the RawURL syntax here since we are using `mrepo`_
to manage our yum mirrors.
.. _mrepo: http://dag.wieers.com/home-made/mrepo/
.. code-block:: xml
<Sources>
<!-- CentOS (5.4) sources -->
<YUMSource>
<Group>centos5.4</Group>
<RawURL>http://mrepo/centos5-x86_64/RPMS.os</RawURL>
<Arch>x86_64</Arch>
</YUMSource>
<YUMSource>
<Group>centos5.4</Group>
<RawURL>http://mrepo/centos5-x86_64/RPMS.updates</RawURL>
<Arch>x86_64</Arch>
</YUMSource>
<YUMSource>
<Group>centos5.4</Group>
<RawURL>http://mrepo/centos5-x86_64/RPMS.extras</RawURL>
<Arch>x86_64</Arch>
</YUMSource>
</Sources>
Due to the `Magic Groups`_, we need to modify our Metadata. Let's
add a **centos5.4** group which inherits a **centos** group
(this should replace the existing **redhat** group) present in
``/var/lib/bcfg2/Metadata/groups.xml``. The resulting file should look
something like this
.. _Magic Groups: http://trac.mcs.anl.gov/projects/bcfg2/wiki/Plugins/Packages#MagicGroups
.. code-block:: xml
<Groups version='3.0'>
<Group profile='true' public='true' default='true' name='basic'>
<Group name='centos5.4'/>
</Group>
<Group name='centos5.4'>
<Group name='centos'/>
</Group>
<Group name='ubuntu'/>
<Group name='debian'/>
<Group name='freebsd'/>
<Group name='gentoo'/>
<Group name='centos'/>
<Group name='suse'/>
<Group name='mandrake'/>
<Group name='solaris'/>
</Groups>
.. note::
When editing your xml files by hand, it is useful to occasionally run
`bcfg2-repo-validate` to ensure that your xml validates properly.
The final thing we need is for the client to have the proper
arch group membership. For this, we will make use of the
:ref:`unsorted-dynamic_groups` capabilities of the Probes plugin. Add
Probes to your plugins line in ``bcfg2.conf`` and create the Probe.::
[root@centos ~]# grep plugins /etc/bcfg2.conf
plugins = Base,Bundler,Cfg,Metadata,Packages,Probes,Rules,SSHbase
[root@centos ~]# mkdir /var/lib/bcfg2/Probes
[root@centos ~]# cat /var/lib/bcfg2/Probes/groups
#!/bin/sh
echo "group:`uname -m`"
Now we restart the bcfg2-server::
/etc/init.d/bcfg2-server restart
If you tail ``/var/log/syslog`` now, you will see the Packages plugin in
action, updating the cache.
Start managing packages
+++++++++++++++++++++++
Add a base-packages bundle. Let's see what happens when we just populate
it with the *yum* package.
.. code-block:: xml
[root@centos ~]# cat /var/lib/bcfg2/Bundler/base-packages.xml
<Bundle name='base-packages'>
<Package name='yum'/>
</Bundle>
You need to reference the bundle from your Metadata. The resulting
profile group might look something like this
.. code-block:: xml
<Group profile='true' public='true' default='true' name='basic'>
<Bundle name='base-packages'/>
<Group name='centos5.4'/>
</Group>
Now if we run the client, we can see what this has done for us.::
[root@centos ~]# bcfg2 -vqn
Running probe groups
Probe groups has result:
x86_64
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Excluding Packages in global exclude list
Finished
Loaded tool drivers:
Action Chkconfig POSIX YUMng
Package pam failed verification.
Phase: initial
Correct entries: 94
Incorrect entries: 1
Total managed entries: 95
Unmanaged entries: 113
In dryrun mode: suppressing entry installation for:
Package:pam
Phase: final
Correct entries: 94
Incorrect entries: 1
Package:pam
Total managed entries: 95
Unmanaged entries: 113
Interesting, our **pam** package failed verification. What does this
mean? Let's have a look::
[root@centos ~]# rpm --verify pam
....L... c /etc/pam.d/system-auth
Sigh, it looks like the default RPM install for pam fails to verify
using its own verification process (trust me, it's not the only one). At
any rate, I was able to get rid of this particular issue by removing the
symlink and running ``yum reinstall pam``.
As you can see, the Packages plugin has generated the dependencies
required for the yum package automatically. The ultimate goal should
be to move all the packages from the **Unmanaged** entries section to
the **Managed** entries section. So, what exactly *are* those Unmanaged
entries?::
[root@centos ~]# bcfg2 -veqn
Running probe groups
Probe groups has result:
x86_64
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Excluding Packages in global exclude list
Finished
Loaded tool drivers:
Action Chkconfig POSIX YUMng
Extra Package openssh-clients 4.3p2-36.el5_4.4.x86_64.
Extra Package libuser 0.54.7-2.1el5_4.1.x86_64.
...
Phase: initial
Correct entries: 95
Incorrect entries: 0
Total managed entries: 95
Unmanaged entries: 113
Phase: final
Correct entries: 95
Incorrect entries: 0
Total managed entries: 95
Unmanaged entries: 113
Package:at
Package:avahi
Package:avahi-compat-libdns_sd
...
Now you can go through these and continue adding the packages you want
to your Bundle. After a while, I ended up with a minimal bundle that
looks like this
.. code-block:: xml
<Bundle name='base-packages'>
<Package name='bcfg2-server'/>
<Package name='exim'/>
<Package name='grub'/>
<Package name='kernel'/>
<Package name='krb5-workstation'/>
<Package name='m2crypto'/>
<Package name='openssh-clients'/>
<Package name='openssh-server'/>
<Package name='prelink'/>
<Package name='redhat-lsb'/>
<Package name='rpm-build'/>
<Package name='rsync'/>
<Package name='sysklogd'/>
<Package name='vim-enhanced'/>
<Package name='yum'/>
</Bundle>
Now when I run the client, you can see I have only one unmanaged
package::
[root@centos ~]# bcfg2 -veqn
Running probe groups
Probe groups has result:
x86_64
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Excluding Packages in global exclude list
Finished
Loaded tool drivers:
Action Chkconfig POSIX YUMng
Extra Package gpg-pubkey e8562897-459f07a4.None.
Extra Package gpg-pubkey 217521f6-45e8a532.None.
Phase: initial
Correct entries: 187
Incorrect entries: 0
Total managed entries: 187
Unmanaged entries: 16
Phase: final
Correct entries: 187
Incorrect entries: 0
Total managed entries: 187
Unmanaged entries: 16
Package:gpg-pubkey
Service:atd
Service:avahi-daemon
Service:bcfg2-server
...
The gpg-pubkey packages are special in that they are not really
packages. Currently, the way to manage them is using :ref:`BoundEntries
<boundentries>`. So, after adding them, our Bundle now looks like this
.. note:: This does not actually control the contents of the files,
you will need to do this part separately (see below).
.. code-block:: xml
<Bundle name='base-packages'>
<BoundPackage name="gpg-pubkey" type="rpm">
<Instance simplefile="/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5" version="e8562897" release="459f07a4"/>
<Instance simplefile="/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL" version="217521f6" release="45e8a532"/>
</BoundPackage>
<Package name='bcfg2-server'/>
<Package name='exim'/>
<Package name='grub'/>
<Package name='kernel'/>
<Package name='krb5-workstation'/>
<Package name='m2crypto'/>
<Package name='openssh-clients'/>
<Package name='openssh-server'/>
<Package name='prelink'/>
<Package name='redhat-lsb'/>
<Package name='rpm-build'/>
<Package name='rsync'/>
<Package name='sysklogd'/>
<Package name='vim-enhanced'/>
<Package name='yum'/>
</Bundle>
To actually push the gpg keys out via Bcfg2, you will need to manage the
files as well. This can be done by adding Path entries for each of the
gpg keys you want to manage
.. code-block:: xml
<Bundle name='base-packages'>
<Path name='/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5'/>
<Path name='/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL'/>
<BoundPackage name="gpg-pubkey" type="rpm">
<Instance simplefile="/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5" version="e8562897" release="459f07a4"/>
<Instance simplefile="/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL" version="217521f6" release="45e8a532"/>
</BoundPackage>
<Package name='bcfg2-server'/>
<Package name='exim'/>
<Package name='grub'/>
<Package name='kernel'/>
<Package name='krb5-workstation'/>
<Package name='m2crypto'/>
<Package name='openssh-clients'/>
<Package name='openssh-server'/>
<Package name='prelink'/>
<Package name='redhat-lsb'/>
<Package name='rpm-build'/>
<Package name='rsync'/>
<Package name='sysklogd'/>
<Package name='vim-enhanced'/>
<Package name='yum'/>
</Bundle>
Then add the files to Cfg::
mkdir -p Cfg/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
cp /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 !$/RPM-GPG-KEY-CentOS-5
mkdir -p Cfg/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
cp /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL !$/RPM-GPG-KEY-EPEL
Now, running the client shows only unmanaged Service entries. Woohoo!
Manage services
+++++++++++++++
Now let's clear up the unmanaged service entries by adding the following
entries to our bundle...
.. code-block:: xml
<!-- basic services -->
<Service name='atd'/>
<Service name='avahi-daemon'/>
<Service name='bcfg2-server'/>
<Service name='crond'/>
<Service name='cups'/>
<Service name='gpm'/>
<Service name='lvm2-monitor'/>
<Service name='mcstrans'/>
<Service name='messagebus'/>
<Service name='netfs'/>
<Service name='network'/>
<Service name='postfix'/>
<Service name='rawdevices'/>
<Service name='sshd'/>
<Service name='syslog'/>
...and bind them in Rules
.. code-block:: xml
[root@centos ~]# cat /var/lib/bcfg2/Rules/services.xml
<Rules priority='1'>
<!-- basic services -->
<Service type='chkconfig' status='on' name='atd'/>
<Service type='chkconfig' status='on' name='avahi-daemon'/>
<Service type='chkconfig' status='on' name='bcfg2-server'/>
<Service type='chkconfig' status='on' name='crond'/>
<Service type='chkconfig' status='on' name='cups'/>
<Service type='chkconfig' status='on' name='gpm'/>
<Service type='chkconfig' status='on' name='lvm2-monitor'/>
<Service type='chkconfig' status='on' name='mcstrans'/>
<Service type='chkconfig' status='on' name='messagebus'/>
<Service type='chkconfig' status='on' name='netfs'/>
<Service type='chkconfig' status='on' name='network'/>
<Service type='chkconfig' status='on' name='postfix'/>
<Service type='chkconfig' status='on' name='rawdevices'/>
<Service type='chkconfig' status='on' name='sshd'/>
<Service type='chkconfig' status='on' name='syslog'/>
</Rules>
Now we run the client and see there are no more unmanaged entries! ::
[root@centos ~]# bcfg2 -veqn
Running probe groups
Probe groups has result:
x86_64
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Excluding Packages in global exclude list
Finished
Loaded tool drivers:
Action Chkconfig POSIX YUMng
Phase: initial
Correct entries: 205
Incorrect entries: 0
Total managed entries: 205
Unmanaged entries: 0
Phase: final
Correct entries: 205
Incorrect entries: 0
Total managed entries: 205
Unmanaged entries: 0
Dynamic (web) Reports
---------------------
Download the `Django`_ rpm and install it. I was able to find an RPM at
ftp://ftp.pbone.net/mirror/download.fedora.redhat.com/pub/fedora/epel/5/x86_64/Django-1.1.1-2.el5.noarch.rpm. You will also need to ``yum install httpd``.
.. _Django: http://www.djangoproject.com/
.. note:: I also had to grab the following RPMs
* ftp://ftp.pbone.net/mirror/ftp.freshrpms.net/pub/freshrpms/pub/dag/redhat/el5/en/x86_64/dag/RPMS/python-simplejson-2.0.5-1.el5.rf.x86_64.rpm
* ftp://ftp.pbone.net/mirror/atrpms.net/el5-x86_64/atrpms/stable/python-sqlite2-2.3.3-3_0.1.el5.x86_64.rpm
* Now we need to create the sqlite database::
[root@centos ~]# python /usr/lib/python2.4/site-packages/Bcfg2/Server/Reports/manage.py syncdb
Creating table auth_permission
Creating table auth_group
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table django_admin_log
Creating table reports_client
Creating table reports_ping
Creating table reports_interaction
Creating table reports_reason
Creating table reports_entries
Creating table reports_entries_interactions
Creating table reports_performance
Creating table reports_internaldatabaseversion
You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): no
Installing index for auth.Permission model
Installing index for auth.Message model
Installing index for admin.LogEntry model
Installing index for reports.Client model
Installing index for reports.Ping model
Installing index for reports.Interaction model
Installing index for reports.Entries model
Installing index for reports.Entries_interactions model
* Add DBStats to the plugins line of bcfg2.conf. The resulting
**[server]** section should look something like this::
[server]
repository = /var/lib/bcfg2
plugins = Base,Bundler,Cfg,DBStats,Metadata,Packages,Probes,Rules,SSHbase
* Start/restart the bcfg2 server
* Run the bcfg2 client in order to populate the statistics database
(this run should take a bit longer since you are uploading the client
statistics to the database).
* Download the static reports content::
root@lucid:~# cd /var/www/
root@lucid:/var/www# svn co https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2/reports
* Configure Apache using :ref:`dynamic-http-install` as a guide
* Copy server/statistics sections of bcfg2.conf to
``/etc/bcfg2-web.conf`` (make sure it is world-readable). You should
then have something like this::
[server]
repository = /var/lib/bcfg2
plugins = Base,Bundler,Cfg,DBStats,Metadata,Packages,Probes,Rules,SSHbase
[statistics]
sendmailpath = /usr/lib/sendmail
database_engine = sqlite3
# 'postgresql', 'mysql', 'mysql_old', 'sqlite3' or 'ado_mssql'.
database_name =
# Or path to database file if using sqlite3.
#<repository>/etc/brpt.sqlite is default path if left empty
database_user =
# Not used with sqlite3.
database_password =
# Not used with sqlite3.
database_host =
# Not used with sqlite3.
database_port =
# Set to empty string for default. Not used with sqlite3.
web_debug = True
* Restart apache and point a browser to your bcfg2 server
|