diff options
-rw-r--r-- | doc/installation/building-packages.txt | 227 | ||||
-rw-r--r-- | doc/installation/index.txt | 2 | ||||
-rw-r--r-- | doc/installation/packages.txt | 81 | ||||
-rw-r--r-- | doc/server/configuration.txt | 2 | ||||
-rw-r--r-- | misc/bcfg2.spec | 14 | ||||
-rwxr-xr-x | redhat/scripts/bcfg2-server.init | 2 | ||||
-rw-r--r-- | src/lib/Bcfg2/Reporting/Collector.py | 9 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Core.py | 24 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Metadata.py | 7 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Packages/Apt.py | 1 | ||||
-rw-r--r-- | src/lib/Bcfg2/settings.py | 7 | ||||
-rwxr-xr-x | src/sbin/bcfg2-reports | 3 |
12 files changed, 274 insertions, 105 deletions
diff --git a/doc/installation/building-packages.txt b/doc/installation/building-packages.txt new file mode 100644 index 000000000..f89b64d9e --- /dev/null +++ b/doc/installation/building-packages.txt @@ -0,0 +1,227 @@ +.. -*- mode: rst -*- +.. vim: ft=rst + +.. _installation-building-packages: + +============================= +Building packages from source +============================= + +Building RPMs +============= + +Building from a tarball +----------------------- + +* Create a directory structure for rpmbuild:: + rpmdev-setuptree + +* Copy the tarball to ``~/rpmbuild/SOURCES/`` +* Extract another copy of it somewhere else (eg: ``/tmp``) and retrieve + the ``misc/bcfg2.spec`` file +* Run the following:: + + rpmbuild -ba bcfg2.spec + +* The resulting RPMs will be in ``~/rpmbuild/RPMS/`` and SRPMs + in ``~/rpmbuild/SRPMS/``. + +Building Debian packages +======================== + +The Bcfg2 project provides a ``debian`` subdirectory with the project's +source that enables users to create their own Debian/Ubuntu compatible +packages (`.deb` files). + +Build deps +---------- + +If the distribution you are building on already has packaged bcfg2 +(even an older version), the following command will likely install the +necessary build dependencies:: + + apt-get build-dep bcfg2 bcfg2-server + +Install source code +------------------- + +Depending on which version of bcfg2 you want build, you can obtain the +source code from the Download_ page or from the project's git repository. +To create a local anonymous working copy of the latest version of the +bcfg2 source code, use a command like the following:: + + git clone git://git.mcs.anl.gov/bcfg2.git + +Update the changelog +-------------------- + +The next step is to update the ``debian/changelog`` file with an +appropriate package version string. Debian packages contain a version +that is extracted from the latest entry in this file. An appropriate +version will help you distinguish your locally built package from one +provided by your distribution. It also helps the packaging system know +when a newer version of the package is available to install. + +It is possible to skip this step, but the packages you build will have +the same version as the source distribution and will be easy to confuse +with other similarly named (but maybe not equivalent) packages. + +The basic format of the package version string to use is this:: + + <UPSTREAM VER>~<UPSTREAM PRE-VER>+<GIT-ID>-0.1+<LOCAL VER> + +.. note:: + The '+', and '-' characters have significance in determining when + one package is newer than another. The following format is believed + to do the right thing in all common situations. + +The components of the package version string are explained below: + +.. glossary:: + + <UPSTREAM VER> + This is the version of the Bcfg source code you are working + from. It will likely be something like `0.9.6` or `1.0`. + + <UPSTREAM PRE-VER> + If you are using a published pre-release of Bcfg2, it will have + a name like `pre1` or `rc1`. Use that string here, otherwise + drop this component from the package version string. + + +<GIT-ID> + If you are building from a local working copy of the git + repository, it is useful to include the revision in the package + version. If you are building from a downloaded copy of the source, + drop this component (including the preceding plus-sign (`+`) + from the package version string. + + +<LOCAL VER> + This is a locally relevant name like your last name or your + domain name, plus the digit `1`. For example, if your family + name is ''Smith'', you could use `smith1`. If you work for + ''Example Inc'', you could use `example1`. + +Here are some examples: + +* If you are building packages for revision 6c681bd from git, and the + latest published version is 1.2.0rc1, the version string should be + `1.2.0rc1+6c681bd-0.1+example1`. +* If you are building packages for the published 1.0 rc1 version, the + version string should be `1.0rc1-0.1+example1`. +* If you are building packages for the published 1.0 version, the version + string should be `1.0-0.1+example1`. + +If you are working on a git working copy of 1.0 pre5 and have the +``devscripts`` package installed, the following command is a convenient +way to create a well formatted changelog entry:: + + REV=$(git log --oneline | head -n 1 | cut -d' ' -f1) + debchange --force-bad-version --preserve --newversion "1.0~pre5+${REV}-0.1+example1" git revision $REV + +Building the package +-------------------- + +With the preliminaries out of the way, building the package is simple.:: + + cd .. # Change into the top level of the source directory + fakeroot dpkg-buildpackage -uc -us + +The freshly built packages will be deposited in the parent of the +current directory (``..``). Examine the output of ``dpkg-buildpackage`` +for details. + +External build systems +---------------------- + +This section describes how to build bcfg2 and deps via external build +systems (Currently only a PPA). Some other possibilities are: + + * #651 Look into project-builder to make more native-system bcfg2 packages available + * http://en.opensuse.org/Build_Service/Deb_builds + +Launchpad PPA +^^^^^^^^^^^^^ + +https://launchpad.net/~bcfg2 + +To upload to the PPA you need to be on the active member list of `Bcfg2 +in Launchpad`_. + +Note that **after each successful upload**, you should wait until the PPA +is built, and then **install it locally** using ``sudo aptitude update; +sudo aptitude install (packagename)`` so the next build doesn't fail on +your local machine. If you don't want to wait for a PPA binary build to +complete, you can "apt-get source (packagename)" and do a local build +before the PPA build is done. + +setup gpg-agent +""""""""""""""" + +Setting up gpg-agent and pinentry prevents you from having to type your +passphrase repeatedly.:: + + sudo aptitude install gnupg-agent pinentry-gtk2 pinentry-curses + # replace 0xAA95C349 with your GPG Key ID + export GPGKEY=0xAA95C349 + killall -q gpg-agent + eval $(gpg-agent --daemon) + +setup debuild +""""""""""""" + +Tell dpkg-buildpackage who you are, for example:: + + export DEBEMAIL="dclark@pobox.com" + export DEBFULLNAME="Daniel Joseph Barnhart Clark" + +upload bcfg2 to ppa +""""""""""""""""""" + +A ``dists`` file contains a space-separated list of all distributions +you want to build PPA packages for. + +.. code-block:: sh + + #!/bin/sh + + . ./dists + + # Replace 0xAA95C349 with your GnuPG Key ID + export GPGKEY=0xAA95C349 + + sudo apt-get build-dep bcfg2 bcfg2-server + sudo aptitude install git + + VERSION=1.3.2-1 + if [ ! -d testing ]; then + mkdir testing + fi + DATE=$(date +%F-%H%M) + ppa="testing" # "testing" or "ppa" (for stable) + + # download source + cd testing + git clone git://git.mcs.anl.gov/bcfg2 + cd bcfg2 + GITID=$(git log --oneline | head -n 1 | cut -d' ' -f1) + cp debian/changelog ../changelog.orig + + for dist in $DISTS + do + cp ../changelog.orig debian/changelog + (cd debian && dch --distribution ${dist} \ + --force-bad-version \ + --preserve \ + --force-distribution \ + --newversion "${VERSION}~${ppa}~${dist}${DATE}+${GITID}" \ + "bcfg2 backport for ${dist} release ${VERSION} git commit ${GITID}") + debuild --no-tgz-check -rfakeroot -I -S -k${GPGKEY} + done + + for dist in $DISTS + do + dput ppa:bcfg2/${dist}testing ../bcfg2_${VERSION}~${ppa}~${dist}${DATE}+${GITID}_source.changes + done + +.. _Download: http://bcfg2.org/download/ +.. _Bcfg2 in Launchpad: https://launchpad.net/~bcfg2 diff --git a/doc/installation/index.txt b/doc/installation/index.txt index 9f04d4b52..9bcf8be15 100644 --- a/doc/installation/index.txt +++ b/doc/installation/index.txt @@ -19,5 +19,5 @@ needs to be installed on any machine you plan to manage by Bcfg2. prerequisites source - packages + building-packages distributions diff --git a/doc/installation/packages.txt b/doc/installation/packages.txt deleted file mode 100644 index b23a870cf..000000000 --- a/doc/installation/packages.txt +++ /dev/null @@ -1,81 +0,0 @@ -.. -*- mode: rst -*- - -.. _packages: - -.. _CentOS: http://www.centos.org/ -.. _Red Hat/RHEL: http://www.redhat.com/rhel/ -.. _Scientific Linux: http://www.scientificlinux.org/ -.. _EPEL: http://fedoraproject.org/wiki/EPEL -.. _RPMForge: https://rpmrepo.org/RPMforge - - -Building RPM packages from source -================================= - -The Bcfg2 distribution contains two different spec files. - -Building from Tarball ---------------------- - -* Copy the tarball to ``/usr/src/packages/SOURCES/`` -* Extract another copy of it somewhere else (eg: ``/tmp``) and retrieve - the ``misc/bcfg2.spec`` file -* Run :: - - rpmbuild -ba bcfg2.spec - -* The resulting RPMs will be in ``/usr/src/packages/RPMS/`` and SRPMs - in ``/usr/src/packages/SRPMS`` - -Building from an GIT Checkout ------------------------------ - -* Change to the ``redhat/`` directory in the working copy -* Run :: - - make - -* The resulting RPMs will be in ``/usr/src/redhat/RPMS/`` and SRPMs - in ``/usr/src/redhat/SRPMS`` and will have the SVN revision appended - -Building RPM packages with ``rpmbuild`` ---------------------------------------- - -While you can go about building all these things from source, this -how to will try and meet the dependencies using packages from EPEL_. -The *el5* and the *el6* package should be compatible with CentOS 5.x. - -* Installation of the EPEL_ repository package :: - - [root@centos ~]# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-6.noarch.rpm - -* Now you can install the rest of the prerequisites :: - - [root@centos ~]# yum install python-genshi python-cheetah python-lxml - -* After installing git, check out the master branch :: - - [root@centos redhat]# git clone git://git.mcs.anl.gov/bcfg2.git - -* Install the ``fedora-packager`` package :: - - [root@centos ~]# yum install fedora-packager - -* A directory structure for the RPM build process has to be established. :: - - [you@centos ~]$ rpmdev-setuptree - -* Change to the *redhat* directory of the checked out Bcfg2 source:: - - [you@centos ~]$ cd bcfg2/redhat/ - -* In the particular directory is a ``Makefile`` which will do the job of - building the RPM packages. You can do this as root, but it's not - recommended:: - - [you@centos redhat]$ make - -* Now the new RPM package can be installed. Please adjust the path to - your RPM package :: - - [root@centos ~]# rpm -ihv /home/YOU/rpmbuild/RPMS/noarch/bcfg2-server-1.0.0-0.2r5835.noarch.rpm diff --git a/doc/server/configuration.txt b/doc/server/configuration.txt index 383367a46..400db40b5 100644 --- a/doc/server/configuration.txt +++ b/doc/server/configuration.txt @@ -229,7 +229,7 @@ By default, the server spawns as many children as the host has CPUs. (This is determined by ``multiprocessing.cpu_count()``.) To change this, set: -.. code-block:: conf +.. code-block:: ini [server] children = 4 diff --git a/misc/bcfg2.spec b/misc/bcfg2.spec index bf37f030a..b2f3fd641 100644 --- a/misc/bcfg2.spec +++ b/misc/bcfg2.spec @@ -30,7 +30,7 @@ Name: bcfg2 Version: 1.3.3 -Release: 3%{?_pre_rc}%{?dist} +Release: 4%{?_pre_rc}%{?dist} Summary: A configuration management system %if 0%{?suse_version} @@ -85,16 +85,16 @@ BuildRequires: m2crypto BuildRequires: python-django %else BuildRequires: Django -%endif -BuildRequires: python-genshi -BuildRequires: python-cheetah -BuildRequires: libselinux-python -%if 0%{?rhel} != 7 +# FIXME: Not yet present in EPEL7; for building docs +BuildRequires: gamin-python # FIXME: Not yet present in EPEL7; for %%check BuildRequires: pylibacl BuildRequires: python-pep8 BuildRequires: pylint %endif +BuildRequires: python-genshi +BuildRequires: python-cheetah +BuildRequires: libselinux-python %if %{build_cherry_py} BuildRequires: python-cherrypy >= 3 %endif @@ -963,7 +963,7 @@ sed "s@http://www.w3.org/2001/xml.xsd@file://$(pwd)/schemas/xml.xsd@" \ - Changed source0 in order that it works with spectool * Sat Jun 19 2010 Fabian Affolter <mail@fabian-affolter.ch> - 1.1.0-0.1.rc3 -- Updated to new upstream release candidate RC3 +- Updated to new upstream release candidate RC3 * Sun May 02 2010 Fabian Affolter <mail@fabian-affolter.ch> - 1.1.0-0.2.rc1 - Changed define to global diff --git a/redhat/scripts/bcfg2-server.init b/redhat/scripts/bcfg2-server.init index c4412d1c3..395189e90 100755 --- a/redhat/scripts/bcfg2-server.init +++ b/redhat/scripts/bcfg2-server.init @@ -49,7 +49,7 @@ start () { stop () { echo -n $"Stopping $prog: " - killproc ${prog} && success || failure + killproc -p ${PIDFILE} -d 10 ${prog} && success || failure RETVAL=$? echo rm -f /var/lock/subsys/$prog diff --git a/src/lib/Bcfg2/Reporting/Collector.py b/src/lib/Bcfg2/Reporting/Collector.py index 52700f917..0493c907b 100644 --- a/src/lib/Bcfg2/Reporting/Collector.py +++ b/src/lib/Bcfg2/Reporting/Collector.py @@ -56,7 +56,7 @@ class ReportingCollector(object): """The collecting process for reports""" def __init__(self, setup): - """Setup the collector. This may be called by the daemon or though + """Setup the collector. This may be called by the daemon or though bcfg2-admin""" self.setup = setup self.datastore = setup['repo'] @@ -99,12 +99,12 @@ class ReportingCollector(object): raise ReportingError try: - self.logger.debug("Validating storage %s" % + self.logger.debug("Validating storage %s" % self.storage.__class__.__name__) self.storage.validate() except: self.logger.error("Storage backed %s failed to validate: %s" % - (self.storage.__class__.__name__, + (self.storage.__class__.__name__, traceback.format_exc().splitlines()[-1])) def run(self): @@ -162,6 +162,9 @@ class ReportingCollector(object): pass if self.storage: self.storage.shutdown() + from django import db + self.logger.info("%s: Closing database connection" % self.name) + db.close_connection() def reap_children(self): """Join any non-live threads""" diff --git a/src/lib/Bcfg2/Server/Core.py b/src/lib/Bcfg2/Server/Core.py index c2cf6b7a4..38daa870e 100644 --- a/src/lib/Bcfg2/Server/Core.py +++ b/src/lib/Bcfg2/Server/Core.py @@ -86,6 +86,7 @@ class BaseCore(object): """ The server core is the container for all Bcfg2 server logic and modules. All core implementations must inherit from ``BaseCore``. """ + name = "core" def __init__(self, setup): # pylint: disable=R0912,R0915 """ @@ -414,7 +415,7 @@ class BaseCore(object): :type plugin: string :returns: None """ - self.logger.debug("Loading plugin %s" % plugin) + self.logger.debug("%s: Loading plugin %s" % (self.name, plugin)) try: mod = getattr(__import__("Bcfg2.Server.Plugins.%s" % (plugin)).Server.Plugins, plugin) @@ -450,14 +451,18 @@ class BaseCore(object): def shutdown(self): """ Perform plugin and FAM shutdown tasks. """ - self.logger.info("Shutting down core...") + self.logger.info("%s: Shutting down core..." % self.name) if not self.terminate.isSet(): self.terminate.set() - self.fam.shutdown() - self.logger.info("FAM shut down") - for plugin in list(self.plugins.values()): - plugin.shutdown() - self.logger.info("All plugins shut down") + self.fam.shutdown() + self.logger.info("%s: FAM shut down" % self.name) + for plugin in list(self.plugins.values()): + plugin.shutdown() + self.logger.info("%s: All plugins shut down" % self.name) + if self._database_available: + from django import db + self.logger.info("%s: Closing database connection" % self.name) + db.close_connection() @property def metadata_cache_mode(self): @@ -726,6 +731,11 @@ class BaseCore(object): self.validate_goals(meta, config) self.client_run_hook("end_client_run", meta) + if self._database_available: + from django import db + self.logger.debug("%s: Closing database connection" % + threading.current_thread().name) + db.close_connection() sort_xml(config, key=lambda e: e.get('name')) diff --git a/src/lib/Bcfg2/Server/Plugins/Metadata.py b/src/lib/Bcfg2/Server/Plugins/Metadata.py index 343e14162..f734c98d0 100644 --- a/src/lib/Bcfg2/Server/Plugins/Metadata.py +++ b/src/lib/Bcfg2/Server/Plugins/Metadata.py @@ -1657,8 +1657,8 @@ class MetadataLint(Bcfg2.Server.Lint.ServerPlugin): "client") def duplicate_groups(self): - """ Check for groups that are defined more than once. There - are two ways this can happen: + """ Check for groups that are defined more than once. There are two + ways this can happen: 1. The group is listed twice with contradictory options. 2. The group is listed with no options *first*, and then with @@ -1674,7 +1674,8 @@ class MetadataLint(Bcfg2.Server.Lint.ServerPlugin): grpname = grp.get("name") if grpname in duplicates: duplicates[grpname].append(grp) - elif len(grp.attrib) > 1: # group has options + elif set(grp.attrib.keys()).difference(['negate', 'name']): + # group has options if grpname in groups: duplicates[grpname] = [grp, groups[grpname]] else: diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Apt.py b/src/lib/Bcfg2/Server/Plugins/Packages/Apt.py index a82a183d8..27a725f23 100644 --- a/src/lib/Bcfg2/Server/Plugins/Packages/Apt.py +++ b/src/lib/Bcfg2/Server/Plugins/Packages/Apt.py @@ -77,6 +77,7 @@ class AptSource(Source): def read_files(self): bdeps = dict() bprov = dict() + self.essentialpkgs = set() depfnames = ['Depends', 'Pre-Depends'] if self.recommended: depfnames.append('Recommends') diff --git a/src/lib/Bcfg2/settings.py b/src/lib/Bcfg2/settings.py index 82a3bdb2a..aa784336d 100644 --- a/src/lib/Bcfg2/settings.py +++ b/src/lib/Bcfg2/settings.py @@ -82,8 +82,13 @@ def read_config(cfile=DEFAULT_CONFIG, repo=None, quiet=False): if repo is None: repo = setup['repo'] + if setup['db_engine'] == 'ibm_db_django': + db_engine = setup['db_engine'] + else: + db_engine = "django.db.backends.%s" % setup['db_engine'] + DATABASES['default'] = \ - dict(ENGINE="django.db.backends.%s" % setup['db_engine'], + dict(ENGINE=db_engine, NAME=setup['db_name'], USER=setup['db_user'], PASSWORD=setup['db_password'], diff --git a/src/sbin/bcfg2-reports b/src/sbin/bcfg2-reports index b0c170b1b..2a8447ae4 100755 --- a/src/sbin/bcfg2-reports +++ b/src/sbin/bcfg2-reports @@ -24,6 +24,7 @@ sys.path.pop() os.environ['DJANGO_SETTINGS_MODULE'] = '%s.settings' % project_name from Bcfg2.Reporting.models import (Client, BaseEntry) +from django import db def hosts_by_entry_type(clients, etype, entryspec): result = [] @@ -293,6 +294,8 @@ def main(): if not client.expiration: print_fields(fields, client, fmt, extra=edata.get(client, None)) + db.close_connection() + if __name__ == "__main__": sys.exit(main()) |