From dfe85636713054d0c5456b16ad873774337ea47b Mon Sep 17 00:00:00 2001 From: Travis Cline Date: Mon, 20 Jun 2011 20:29:26 -0500 Subject: [PATCH] Added new option: root_dir to be prepended to 'pki_dir', 'cachedir', and 'log_file' to aid in non-root installations. --- conf/master | 3 +++ conf/minion | 3 +++ salt/config.py | 17 +++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/conf/master b/conf/master index ba418cced0a..3e4987093f4 100644 --- a/conf/master +++ b/conf/master @@ -21,6 +21,9 @@ # The port used by the communication interface #ret_port: 4506 +# The root directory prepended to these options: pki_dir, cachedir, log_file. +#root_dir: / + # Directory used to store public key data #pki_dir: /etc/salt/pki diff --git a/conf/minion b/conf/minion index da5730174de..5420b6e2d19 100644 --- a/conf/minion +++ b/conf/minion @@ -7,6 +7,9 @@ # Set the post used by the master reply and authentication server #master_port: 4506 +# The root directory prepended to these options: pki_dir, cachedir, log_file. +#root_dir: / + # The directory to store the pki information in #pki_dir: /etc/salt/pki diff --git a/salt/config.py b/salt/config.py index 7ee9dd79fac..fd6bcaea4c1 100644 --- a/salt/config.py +++ b/salt/config.py @@ -28,12 +28,22 @@ def load_config(opts, path, env_var): else: print 'Missing configuration file: %s' % path +def prepend_root_dir(opts): + ''' + Prepends the options that represent filesystem paths with value of the + 'root_dir' option. + ''' + path_options = ('pki_dir', 'cachedir', 'log_file') + for path_option in path_options: + opts[path_option] = os.path.normpath(os.sep.join([opts['root_dir'], opts[path_option]])) + def minion_config(path): ''' Reads in the minion configuration file and sets up special options ''' opts = {'master': 'salt', 'master_port': '4506', + 'root_dir': '/', 'pki_dir': '/etc/salt/pki', 'id': socket.getfqdn(), 'cachedir': '/var/cache/salt', @@ -69,6 +79,9 @@ def minion_config(path): opts['grains'] = salt.loader.grains(opts) + # Prepend root_dir to other paths + prepend_root_dir(opts) + return opts def master_config(path): @@ -82,6 +95,7 @@ def master_config(path): 'worker_start_port': '45056', 'ret_port': '4506', 'keep_jobs': 24, + 'root_dir': '/', 'pki_dir': '/etc/salt/pki', 'cachedir': '/var/cache/salt', 'file_roots': { @@ -105,6 +119,9 @@ def master_config(path): opts['aes'] = salt.crypt.Crypticle.generate_key_string() + # Prepend root_dir to other paths + prepend_root_dir(opts) + # Enabling open mode requires that the value be set to True, and nothing # else! if opts['open_mode']: