Added ignore symlink option. Cleaned up roots.

This commit is contained in:
Mickey Malone 2013-09-20 20:25:48 -05:00
parent e46fae6a2e
commit 105806ead3
3 changed files with 16 additions and 9 deletions

View file

@ -313,7 +313,14 @@
# fileserver_backend.
#
#fileserver_followsymlinks: False
#
# Uncomment the line below if you do not want symlinks to be
# treated as the files they are pointinig to. By default this is set to
# False. By uncommenting the line below, any detected symlink while listing
# files on the Master will not be returned to the Minion.
#
#fileserver_ignoresymlinks: True
#
# Git fileserver backend configuration
# When using the git fileserver backend at least one git remote needs to be
# defined. The user running the salt master will need read access to the repo.

View file

@ -141,6 +141,7 @@ VALID_OPTS = {
'file_ignore_glob': bool,
'fileserver_backend': list,
'fileserver_followsymlinks': bool,
'fileserver_ignoresymlinks': bool,
'max_open_files': int,
'auto_accept': bool,
'master_tops': bool,
@ -292,6 +293,7 @@ DEFAULT_MASTER_OPTS = {
'file_ignore_glob': None,
'fileserver_backend': ['roots'],
'fileserver_followsymlinks': True,
'fileserver_ignoresymlinks': False,
'max_open_files': 100000,
'hash_type': 'md5',
'conf_file': os.path.join(syspaths.CONFIG_DIR, 'master'),

View file

@ -183,11 +183,11 @@ def file_list(load):
prefix = load['prefix'].strip('/')
except KeyError:
prefix = ''
for root, dirs, files in os.walk(os.path.join(path, prefix),
followlinks=True if __opts__['fileserver_followsymlinks']
else followlinks=False):
for root, dirs, files in os.walk(os.path.join(path, prefix),
followlinks=__opts__['fileserver_followsymlinks']):
for fname in files:
if __opts__['fileserver_ignoresymlinks'] and os.path.islink(os.path.join(root, fname)):
continue
rel_fn = os.path.relpath(
os.path.join(root, fname),
path
@ -210,8 +210,7 @@ def file_list_emptydirs(load):
except KeyError:
prefix = ''
for root, dirs, files in os.walk(os.path.join(path, prefix),
followlinks=True if __opts__['fileserver_followsymlinks']
else followlinks=False):
followlinks=__opts__['fileserver_followsymlinks']):
if len(dirs) == 0 and len(files) == 0:
rel_fn = os.path.relpath(root, path)
if not salt.fileserver.is_file_ignored(__opts__, rel_fn):
@ -232,7 +231,6 @@ def dir_list(load):
except KeyError:
prefix = ''
for root, dirs, files in os.walk(os.path.join(path, prefix),
followlinks=True if __opts__['fileserver_followsymlinks']
else followlinks=False):
followlinks=__opts__['fileserver_followsymlinks']):
ret.append(os.path.relpath(root, path))
return ret