Merge pull request #9992 from pakdel/issue-9932

Fixed Issue #9932: Only the first git repository is initialized and working using git_pillar
This commit is contained in:
Thomas S Hatch 2014-01-31 09:27:59 -08:00
commit 1a0581c8fd
3 changed files with 19 additions and 10 deletions

View File

@ -195,12 +195,11 @@ class Master(SMaster):
ckminions = salt.utils.minions.CkMinions(self.opts)
event = salt.utils.event.MasterEvent(self.opts['sock_dir'])
pillargitfs = None
pillargitfs = []
for opts_dict in [x for x in self.opts.get('ext_pillar', [])]:
if 'git' in opts_dict:
br, loc = opts_dict['git'].strip().split()
pillargitfs = git_pillar.GitPillar(br, loc, self.opts)
break
pillargitfs.append(git_pillar.GitPillar(br, loc, self.opts))
old_present = set()
while True:
@ -248,8 +247,8 @@ class Master(SMaster):
salt.utils.verify.check_max_open_files(self.opts)
try:
if pillargitfs is not None:
pillargitfs.update()
for pillargit in pillargitfs:
pillargit.update()
except Exception as exc:
log.error('Exception {0} occurred in file server update '
'for git_pillar module.'.format(exc))

View File

@ -341,10 +341,18 @@ class Pillar(object):
errors = []
fn_ = self.client.get_state(sls, saltenv).get('dest', False)
if not fn_:
if self.opts['pillar_roots'].get(saltenv):
msg = ('Specified SLS {0!r} in environment {1!r} is not'
' available on the salt master').format(sls, saltenv)
log.error(msg)
errors.append(msg)
else:
log.debug('Specified SLS {0!r} in environment {1!r} is not'
' found, which might be due to environment {1!r}'
' not being present in "pillar_roots" yet!'
.format(sls, saltenv))
# return state, mods, errors
return None, mods, errors
state = None
try:
state = compile_template(

View File

@ -217,10 +217,12 @@ def ext_pillar(minion_id, pillar, repo_string):
if __opts__['pillar_roots'].get(branch, []) == [gitpil.working_dir]:
return {}
gitpil.update()
opts = deepcopy(__opts__)
opts['pillar_roots'][branch] = [gitpil.working_dir]
pil = Pillar(opts, __grains__, minion_id, 'base')
pil = Pillar(opts, __grains__, minion_id, branch)
return pil.compile_pillar()