diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-08-27 10:41:03 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-08-27 10:43:25 -0400 |
commit | af363ce540bd2510e06d55b53b39010df69037de (patch) | |
tree | d9102b31ac00804bb90b0ebee1b92ab68644614d | |
parent | 935ff8b432af9a62002993e3e4c7bb789506fc29 (diff) | |
download | bcfg2-af363ce540bd2510e06d55b53b39010df69037de.tar.gz bcfg2-af363ce540bd2510e06d55b53b39010df69037de.tar.bz2 bcfg2-af363ce540bd2510e06d55b53b39010df69037de.zip |
Packages: added support for generating Apt sources.list
-rw-r--r-- | doc/server/plugins/generators/packages.txt | 46 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Packages/Apt.py | 15 |
2 files changed, 47 insertions, 14 deletions
diff --git a/doc/server/plugins/generators/packages.txt b/doc/server/plugins/generators/packages.txt index 43db251b0..db463c45a 100644 --- a/doc/server/plugins/generators/packages.txt +++ b/doc/server/plugins/generators/packages.txt @@ -416,30 +416,46 @@ need to use :ref:`BoundEntries <boundentries>`, e.g.: Generating Client APT/Yum Configurations ======================================== -.. versionadded:: 1.2.0 +The Packages plugin has native support for generating Yum and Apt +configs. Simply add entries like these to the appropriate bundles: + +.. code-block:: xml -The Packages plugin has native support for generating Yum configs. -You must set ``yum_config`` in ``bcfg2.conf`` to the path to the yum -config file you want to generate:: + <Path name="/etc/yum.repos.d/bcfg2.repo"/> + <Path name="/etc/apt/sources.d/bcfg2"/> + +If you want to change the path to either of those files, you can set +``yum_config`` or ``apt_config`` in ``bcfg2.conf`` to the path to the +config files you want to generate:: [packages] yum_config=/etc/yum.repos.d/all.repo + apt_config=/etc/apt/sources.d/all -Then add the corresponding Path entry to your Yum bundle. +If you need to distribute a config to different places on different +hosts, you can use the :ref:`server-plugins-structures-altsrc` +attribute, e.g.: -.. versionadded:: 1.1.0 +.. code-block:: xml -APT repository information can be generated automatically from -software sources using :doc:`./tgenshi/index` or :doc:`./tcheetah`. A -list of source urls are exposed in the client's metadata as -``metadata.Packages.sources``. E.g.:: + <Bundle name="yum"> + <Group name="sles"> + <Path name="/etc/yum/yum.repos.d/bcfg2.repo" + altsrc="/etc/yum.repos.d/bcfg2.repo"/> + </Group> + <Group name="sles" negate="true"> + <Path name="/etc/yum.repos.d/bcfg2.repo"/> + </Group> + </Bundle> - # bcfg2 maintained apt +See :ref:`configuration` for more details on these options. - {% for s in metadata.Packages.sources %}\ - deb ${s.url}${s.version} ${s.groups[0]} {% for comp in s.components %}$comp {% end %} +.. note:: - {% end %}\ + Support for generating Yum configs was added in 1.2.0, and Apt + configs was added in 1.3.0. Before that, you could use + :doc:`./tgenshi/index` or :doc:`./tcheetah` to generate your + configs. .. _native-yum-libraries: @@ -689,6 +705,8 @@ multiple data sources need to be multiplexed. The APT source in ``src/lib/Server/Plugins/Packages.py`` provides a relatively simple implementation of a source. +.. _configuration: + Configuration ============= diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Apt.py b/src/lib/Bcfg2/Server/Plugins/Packages/Apt.py index 06730562a..d182453e6 100644 --- a/src/lib/Bcfg2/Server/Plugins/Packages/Apt.py +++ b/src/lib/Bcfg2/Server/Plugins/Packages/Apt.py @@ -10,6 +10,21 @@ class AptCollection(Collection): "supported by APT") return [] + def get_config(self): + lines = ["# This config was generated automatically by the Bcfg2 " \ + "Packages plugin", ''] + + sources = dict() + for source in self.sources: + if source.rawurl: + self.logger.info("Packages: Skipping rawurl %s" % source.rawurl) + else: + lines.append("deb %s %s %s" % (source.url, source.version, + " ".join(source.components))) + lines.append("") + + return "\n".join(lines) + class AptSource(Source): basegroups = ['apt', 'debian', 'ubuntu', 'nexenta'] |