From b7a4daa305372e75145700517ddd061572a33386 Mon Sep 17 00:00:00 2001 From: Todd Zullinger Date: Sun, 15 Mar 2009 22:02:31 -0400 Subject: Support system-wide config file This reads /etc/puppet/hostpackage.conf and then ~/.puppethost, with the latter overriding settings from the former. --- puppethost.py | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/puppethost.py b/puppethost.py index 6a08ae3..a4b6106 100644 --- a/puppethost.py +++ b/puppethost.py @@ -47,23 +47,24 @@ try: except: pass -config = os.path.expanduser('~/.puppethost') -if os.path.exists(config): - execfile(config, {}, defaults) - truths = ['true', 'yes', '1'] - # Ensure boolean options are set correctly - for opt in ['force', 'force_cert', 'force_tarball', 'force_package']: - defaults[opt] = str(defaults[opt]).lower() in truths - # Ensure numeric options are set correctly - for opt in ['verbose']: - if isinstance(defaults[opt], bool): - defaults[opt] = int(defaults[opt]) - elif not isinstance(defaults[opt], int): - try: - defaults[opt] = int(str(defaults[opt]).lower() in truths) - except: - raise - defaults[opt] = 0 +configs = ['/etc/puppet/hostpackage.conf', os.path.expanduser('~/.puppethost')] +for config in configs: + if os.path.exists(config): + execfile(config, {}, defaults) + truths = ['true', 'yes', '1'] + # Ensure boolean options are set correctly + for opt in ['force', 'force_cert', 'force_tarball', 'force_package']: + defaults[opt] = str(defaults[opt]).lower() in truths + # Ensure numeric options are set correctly + for opt in ['verbose']: + if isinstance(defaults[opt], bool): + defaults[opt] = int(defaults[opt]) + elif not isinstance(defaults[opt], int): + try: + defaults[opt] = int(str(defaults[opt]).lower() in truths) + except: + raise + defaults[opt] = 0 package_types = ['deb', 'rpm'] -- cgit