From 81e936424b9f2a9ada20a83ca9353b5c0609b28c Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Thu, 18 Aug 2011 12:06:54 -0400 Subject: added --altsrc flag to bcfg2-info buildfile --- doc/help/troubleshooting.txt | 3 ++- doc/server/plugins/generators/tgenshi/index.txt | 23 ++++++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'doc') diff --git a/doc/help/troubleshooting.txt b/doc/help/troubleshooting.txt index b0eeca33e..7aeb0f247 100644 --- a/doc/help/troubleshooting.txt +++ b/doc/help/troubleshooting.txt @@ -70,7 +70,8 @@ operations * clients - Current client metadata (profile and group) settings * groups - Current group metadata values * mappings - Configuration entries provided by plugins -* buildfile - Build a config file for a client +* buildfile [--altsrc=] - Build a config + file for a client * buildbundle - Render a templated bundle for a client * showentries - Build the abstract configuration (list of entries) for a client diff --git a/doc/server/plugins/generators/tgenshi/index.txt b/doc/server/plugins/generators/tgenshi/index.txt index d7e0b3bf2..c5392dcc4 100644 --- a/doc/server/plugins/generators/tgenshi/index.txt +++ b/doc/server/plugins/generators/tgenshi/index.txt @@ -106,29 +106,31 @@ E.g.:: bcfg2-info buildfile /etc/foo.conf foo.example.com +To generate a file with an altsrc attribute, you can run:: + + bcfg2-info buildfile /etc/foo/foo.conf --altsrc=/etc/foo.conf \ + foo.example.com + Sometimes, it's useful to be able to do more in-depth troubleshooting -by running the template manually. (This is also necessary if you want -to generate a template that depends on an :ref:`altsrc -` tag.) To do this, run ``bcfg2-info +by running the template manually. To do this, run ``bcfg2-info debug``, and, once in the Python interpreter, run:: metadata = self.build_metadata("") path = "" - bcfg2root = "" ``path`` should be set to the path to the template file with a leading slash, relative to the Bcfg2 specification root. See `Inside of Templates`_ for examples. -``bcfg2root`` should be set to the absolute path to the Bcfg2 -specification. (This is ``/var/lib/bcfg2`` by default.) - Then, run:: - import os - name = os.path.dirname(path[path.find('/', 1):]) + import os, Bcfg2.Options from genshi.template import TemplateLoader, NewTextTemplate - template = TemplateLoader().load(bcfg2root + path, cls=NewTextTemplate) + name = os.path.dirname(path[path.find('/', 1):]) + setup = Bcfg2.Options.OptionParser({'repo': + Bcfg2.Options.SERVER_REPOSITORY}) + setup.parse('--') + template = TemplateLoader().load(set['repo'] + path, cls=NewTextTemplate) print template.generate(metadata=metadata, path=path, name=name).render() This gives you more fine-grained control over how your template is @@ -141,7 +143,6 @@ to the file to be generated, e.g.:: metadata = self.build_metadata("foo.example.com") path = "/Cfg/etc/sysconfig/network-scripts/ifcfg-template/ifcfg-template.genshi" - bcfg2root = "/var/lib/bcfg2" name = "/etc/sysconfig/network-scripts/ifcfg-bond0" File permissions -- cgit v1.2.3-1-g7c22