Added new option: root_dir to be prepended to 'pki_dir', 'cachedir', and 'log_file' to aid in non-root installations.

This commit is contained in:
Travis Cline 2011-06-20 20:29:26 -05:00
parent 7ae8805279
commit dfe8563671
3 changed files with 23 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -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']: