diff options
-rw-r--r-- | doc/glossary.txt | 2 | ||||
-rw-r--r-- | doc/reports/dynamic.txt | 9 | ||||
-rw-r--r-- | doc/server/plugins/generators/tgenshi/index.txt | 2 | ||||
-rw-r--r-- | misc/bcfg2.spec | 2 | ||||
-rw-r--r-- | src/lib/Bcfg2/Client/Tools/MacPorts.py | 13 | ||||
-rw-r--r-- | src/lib/Bcfg2/Client/Tools/launchd.py | 53 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Packages/Source.py | 5 | ||||
-rwxr-xr-x | src/sbin/bcfg2-info | 34 |
8 files changed, 78 insertions, 42 deletions
diff --git a/doc/glossary.txt b/doc/glossary.txt index 5455e9ced..06f67dab9 100644 --- a/doc/glossary.txt +++ b/doc/glossary.txt @@ -33,8 +33,6 @@ Glossary profile A special type of group that a client is explicitly assigned to. - structure - repository A collection of folders and files that together define the configurations that Bcfg2 applies to clients. The repository diff --git a/doc/reports/dynamic.txt b/doc/reports/dynamic.txt index 4c75cce32..07763922c 100644 --- a/doc/reports/dynamic.txt +++ b/doc/reports/dynamic.txt @@ -71,6 +71,15 @@ Apache configuration for web-based reports by adding a **web_prefix** setting in the [statistics] section of your ``bcfg2.conf``. +.. warning:: + + When running with SELINUX enabled, you can have potential problems + with the WSGISocketPrefix. One solution that works without too much + trouble is modifying your prefix so that it is located in a standard + location:: + + WSGISocketPrefix /var/run/httpd/wsgi + An example site config is included below:: <IfModule mod_wsgi.c> diff --git a/doc/server/plugins/generators/tgenshi/index.txt b/doc/server/plugins/generators/tgenshi/index.txt index c5392dcc4..21ef8f17f 100644 --- a/doc/server/plugins/generators/tgenshi/index.txt +++ b/doc/server/plugins/generators/tgenshi/index.txt @@ -130,7 +130,7 @@ Then, run:: setup = Bcfg2.Options.OptionParser({'repo': Bcfg2.Options.SERVER_REPOSITORY}) setup.parse('--') - template = TemplateLoader().load(set['repo'] + path, cls=NewTextTemplate) + template = TemplateLoader().load(setup['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 diff --git a/misc/bcfg2.spec b/misc/bcfg2.spec index 866f2f6ba..86c277a25 100644 --- a/misc/bcfg2.spec +++ b/misc/bcfg2.spec @@ -46,7 +46,7 @@ BuildRequires: libsane1 BuildRequires: python-sphinx10 # the python-sphinx10 package doesn't set sys.path correctly, so we # have to do it for them -%define pythonpath %(find /usr/lib/python%{py_ver}/site-packages -name %Sphinx*.egg) +%define pythonpath %(find /usr/lib/python%{py_ver}/site-packages -name Sphinx*.egg) %else BuildRequires: python-sphinx >= 0.6 %endif diff --git a/src/lib/Bcfg2/Client/Tools/MacPorts.py b/src/lib/Bcfg2/Client/Tools/MacPorts.py index e8c911390..9724fab57 100644 --- a/src/lib/Bcfg2/Client/Tools/MacPorts.py +++ b/src/lib/Bcfg2/Client/Tools/MacPorts.py @@ -10,7 +10,7 @@ class MacPorts(Bcfg2.Client.Tools.PkgTool): __handles__ = [('Package', 'macport')] __req__ = {'Package': ['name', 'version']} pkgtype = 'macport' - pkgtool = ("/opt/local/bin/port install %s") + pkgtool = ('/opt/local/bin/port install %s', ('%s', ['name'])) def __init__(self, logger, setup, config): Bcfg2.Client.Tools.PkgTool.__init__(self, logger, setup, config) @@ -26,7 +26,7 @@ class MacPorts(Bcfg2.Client.Tools.PkgTool): continue pkgname = pkg.split('@')[0].strip() version = pkg.split('@')[1].split(' ')[0] - self.logger.info(" pkgname: %s\n version: %s" % (pkgname, version)) + self.logger.info(" pkgname: %s version: %s" % (pkgname, version)) self.installed[pkgname] = version def VerifyPackage(self, entry, modlist): @@ -37,13 +37,20 @@ class MacPorts(Bcfg2.Client.Tools.PkgTool): return False if entry.attrib['name'] in self.installed: - if self.installed[entry.attrib['name']] == entry.attrib['version']: + if (self.installed[entry.attrib['name']] == entry.attrib['version'] or + entry.attrib['version'] == 'any'): #if not self.setup['quick'] and \ # entry.get('verify', 'true') == 'true': #FIXME: We should be able to check this once # http://trac.macports.org/ticket/15709 is implemented return True else: + self.logger.info(" %s: Wrong version installed. " + "Want %s, but have %s" % (entry.get("name"), + entry.get("version"), + self.installed[entry.get("name")], + )) + entry.set('current_version', self.installed[entry.get('name')]) return False entry.set('current_exists', 'false') diff --git a/src/lib/Bcfg2/Client/Tools/launchd.py b/src/lib/Bcfg2/Client/Tools/launchd.py index 700234cc8..c022d32ae 100644 --- a/src/lib/Bcfg2/Client/Tools/launchd.py +++ b/src/lib/Bcfg2/Client/Tools/launchd.py @@ -1,7 +1,6 @@ """launchd support for Bcfg2.""" import os -import popen2 import Bcfg2.Client.Tools @@ -26,7 +25,8 @@ class launchd(Bcfg2.Client.Tools.Tool): /Library/LaunchDaemons System wide daemons provided by the administrator. /System/Library/LaunchAgents Mac OS X Per-user agents. /System/Library/LaunchDaemons Mac OS X System wide daemons.''' - plistLocations = ["/Library/LaunchDaemons", "/System/Library/LaunchDaemons"] + plistLocations = ["/Library/LaunchDaemons", + "/System/Library/LaunchDaemons"] self.plistMapping = {} for directory in plistLocations: for daemon in os.listdir(directory): @@ -35,11 +35,12 @@ class launchd(Bcfg2.Client.Tools.Tool): d = daemon[:-6] else: d = daemon - (stdout, _) = popen2.popen2('defaults read %s/%s Label' % (directory, d)) - label = stdout.read().strip() + label = self.cmd.run('defaults read %s/%s Label' % + (directory, d))[1][0] self.plistMapping[label] = "%s/%s" % (directory, daemon) - except KeyError: #perhaps this could be more robust - pass + except KeyError: + self.logger.warning("Could not get label from %s/%s" % + (directory, daemon)) def FindPlist(self, entry): return self.plistMapping.get(entry.get('name'), None) @@ -60,20 +61,26 @@ class launchd(Bcfg2.Client.Tools.Tool): """Verify launchd service entry.""" try: services = self.cmd.run("/bin/launchctl list")[1] - except IndexError:#happens when no services are running (should be never) + except IndexError: + # happens when no services are running (should be never) services = [] # launchctl output changed in 10.5 - # It is now three columns, with the last column being the name of the # service + # It is now three columns, with the last + # column being the name of the # service version = self.os_version() if version.startswith('10.5') or version.startswith('10.6'): services = [s.split()[-1] for s in services] - if entry.get('name') in services:#doesn't check if non-spawning services are Started + if entry.get('name') in services: + # doesn't check if non-spawning services are Started return entry.get('status') == 'on' else: - self.logger.debug("Didn't find service Loaded (launchd running under same user as bcfg)") + self.logger.debug("Launchd: Didn't find service Loaded " + "(launchd running under same user as bcfg)") return entry.get('status') == 'off' - try: #Perhaps add the "-w" flag to load and unload to modify the file itself! + try: + # Perhaps add the "-w" flag to load and + # unload to modify the file itself! self.cmd.run("/bin/launchctl load -w %s" % self.FindPlist(entry)) except IndexError: return 'on' @@ -89,12 +96,14 @@ class launchd(Bcfg2.Client.Tools.Tool): name = entry.get('name') if entry.get('status') == 'on': self.logger.error("Installing service %s" % name) - cmdrc = self.cmd.run("/bin/launchctl load -w %s" % self.FindPlist(entry)) + cmdrc = self.cmd.run("/bin/launchctl load -w %s" % + self.FindPlist(entry)) cmdrc = self.cmd.run("/bin/launchctl start %s" % name) else: self.logger.error("Uninstalling service %s" % name) cmdrc = self.cmd.run("/bin/launchctl stop %s" % name) - cmdrc = self.cmd.run("/bin/launchctl unload -w %s" % self.FindPlist(entry)) + cmdrc = self.cmd.run("/bin/launchctl unload -w %s" % + self.FindPlist(entry)) return cmdrc[0] == 0 def Remove(self, svcs): @@ -119,17 +128,23 @@ class launchd(Bcfg2.Client.Tools.Tool): """Reload launchd plist.""" for entry in [entry for entry in bundle if self.handlesEntry(entry)]: if not self.canInstall(entry): - self.logger.error("Insufficient information to restart service %s" % (entry.get('name'))) + self.logger.error("Insufficient information to restart service %s" % + (entry.get('name'))) else: name = entry.get('name') if entry.get('status') == 'on' and self.FindPlist(entry): self.logger.info("Reloading launchd service %s" % name) - #stop? + # stop? self.cmd.run("/bin/launchctl stop %s" % name) - self.cmd.run("/bin/launchctl unload -w %s" % (self.FindPlist(entry)))#what if it disappeared? how do we stop services that are currently running but the plist disappeared?! - self.cmd.run("/bin/launchctl load -w %s" % (self.FindPlist(entry))) + # what if it disappeared? how do we stop services + # that are currently running but the plist disappeared?! + self.cmd.run("/bin/launchctl unload -w %s" % + (self.FindPlist(entry))) + self.cmd.run("/bin/launchctl load -w %s" % + (self.FindPlist(entry))) self.cmd.run("/bin/launchctl start %s" % name) else: - #only if necessary.... + # only if necessary.... self.cmd.run("/bin/launchctl stop %s" % name) - self.cmd.run("/bin/launchctl unload -w %s" % (self.FindPlist(entry))) + self.cmd.run("/bin/launchctl unload -w %s" % + (self.FindPlist(entry))) diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Source.py b/src/lib/Bcfg2/Server/Plugins/Packages/Source.py index 5394a4bbd..a7c246940 100644 --- a/src/lib/Bcfg2/Server/Plugins/Packages/Source.py +++ b/src/lib/Bcfg2/Server/Plugins/Packages/Source.py @@ -136,8 +136,9 @@ class Source(Bcfg2.Server.Plugin.Debuggable): def get_repo_name(self, url_map): # try to find a sensible name for a repo - if url_map['component']: - rname = url_map['component'] + if url_map['components']: + # use the first component as the name + rname = url_map['components'][0] else: name = None for repo_re in (self.mrepo_re, diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info index 580de5248..f4d199001 100755 --- a/src/sbin/bcfg2-info +++ b/src/sbin/bcfg2-info @@ -44,7 +44,7 @@ groups - List groups help - Print this list of available commands mappings <type*> <name*> - Print generator mappings for optional type and name packageresolve <hostname> <package> [<package>...] - Resolve the specified set of packages -packagesources - Show package sources +packagesources <hostname> - Show package sources profile <command> <args> - Profile a single bcfg2-info command quit - Exit the bcfg2-info command line showentries <hostname> <type> - Show abstract configuration entries for a given host @@ -506,20 +506,26 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core): # get_urls() loads url_map as a side-effect source.get_urls() for url_map in source.url_map: - if url_map['arch'] in metadata.groups: - reponame = source.get_repo_name(url_map) - print("Name: %s" % reponame) - print(" Type: %s" % source.ptype) + for arch in url_map['arches']: + # make sure client is in all the proper arch groups + if arch not in metadata.groups: + continue + reponame = source.get_repo_name(url_map) + print("Name: %s" % reponame) + print(" Type: %s" % source.ptype) + if url_map['url'] != '': print(" URL: %s" % url_map['url']) - if source.gpgkeys: - print(" GPG Key(s): %s" % ", ".join(source.gpgkeys)) - else: - print(" GPG Key(s): None") - if len(source.blacklist): - print(" Blacklist: %s" % ", ".join(source.blacklist)) - if len(source.whitelist): - print(" Whitelist: %s" % ", ".join(source.whitelist)) - print("") + elif url_map['rawurl'] != '': + print(" RAWURL: %s" % url_map['rawurl']) + if source.gpgkeys: + print(" GPG Key(s): %s" % ", ".join(source.gpgkeys)) + else: + print(" GPG Key(s): None") + if len(source.blacklist): + print(" Blacklist: %s" % ", ".join(source.blacklist)) + if len(source.whitelist): + print(" Whitelist: %s" % ", ".join(source.whitelist)) + print("") def do_profile(self, arg): """.""" |