self.print_out(msg)
print()
- self.check_data_dir()
+ try:
+ self.check_data_dir()
+ except BaseHookError as e:
+ if self.simulate:
+ LOG.error(str(e))
+ else:
+ six.reraise(*sys.exc_info())
self.init_puppet_environments()
self.collect_local_modules()
self.get_forge_information()
appname=self.appname, verbose=self.verbose, base_dir=self.base_dir)
for env in self.environments:
+ LOG.debug("Evaluating environment {!r} ..".format(env))
self.read_puppetfile(env)
self.read_metadata_files(env)
if self.verbose > 2:
for module_dir in glob.glob(pattern):
module_info = self.get_meta_module_info(module_dir, env)
if module_info:
- full_name = module_info.full_name
- if full_name in self.modules:
- self.modules[full_name].merge_in(module_info)
- else:
- self.modules[full_name] = module_info
+ if self.verbose > 1:
+ LOG.debug("Got infos about module {!r}".format(module_info.full_name))
+ elif self.verbose > 2:
+ LOG.debug("Got module info:\n{}".format(pp(module_info.as_dict())))
+ self.modules.merge(module_info)
+ else:
+ LOG.warn("Got no module info from direcrory {!r}".format(module_dir))
# -------------------------------------------------------------------------
def get_meta_module_info(self, module_dir, env):
- if self.verbose > 2:
+ if self.verbose > 1:
LOG.debug("Get module information from {!r}.".format(module_dir))
if not os.path.exists(module_dir):
# -------------------------------------------------------------------------
def read_puppetfile(self, env):
+ LOG.info("Reading Puppetfile of environment {!r} ..".format(env))
+
pfile = Puppetfile(
env_root_dir=self.puppet_root_env_dir, environment=env,
appname=self.appname, verbose=self.verbose, base_dir=self.base_dir,
if self.verbose > 1:
LOG.debug("Got Puppetfile:\n{}".format(pp(pfile.as_dict())))
+ pfile_modules = None
try:
- self.modules = pfile.read_modules()
+ pfile_modules = pfile.read_modules()
except PuppetfileError as e:
LOG.warn(str(e))
- self.modules = ModuleInfoDict(
- appname=self.appname, verbose=self.verbose, base_dir=self.base_dir)
else:
if self.verbose > 2:
LOG.debug("Successful read {!r}.".format(pfile.filename))
+ if pfile_modules:
+ for module_info in pfile_modules.values():
+ self.modules.merge(module_info)
# -------------------------------------------------------------------------
def init_puppet_environments(self):
LOG.info("Trying to open {!r} exclusive ...".format(tmp_file))
+ if self.simulate:
+ LOG.info("Simulation mode, cache file will not be written.")
+ return
+
try:
fd = os.open(tmp_file, os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0o644)
fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB)