LOG.warn("Executing {!r} was not successful.".format(self.r10k_bin))
return
+ if not self.generate_puppet_types():
+ msg = "'{c} generate types --environment {e}' was not successful.".format(
+ self.puppet_bin, self.ref)
+ LOG.warn(msg)
+ return
+
return self.del_env_cache()
# -------------------------------------------------------------------------
self.print_out(msg)
return
+ # -------------------------------------------------------------------------
+ def generate_puppet_types(self):
+ """Generates definitions for custom resource types using Puppet code
+ for the given environment."""
+
+ res = True
+
+ cmd = [
+ self.puppet_bin, 'generate', 'types',
+ '--environment', self.ref,
+ '--color', 'false', ]
+
+ if self.verbose > 1:
+ cmd.append('--verbose')
+ if self.verbose > 3:
+ cmd.append('--debug')
+
+ (ret_val, stdoutdata, stderrdata) = self.handler.call(cmd, sudo=self.do_sudo)
+
+ if stdoutdata:
+ msg = "Output:\n{}".format(to_str(stdoutdata))
+ self.print_out(msg)
+ else:
+ LOG.debug("No output.")
+
+ if stderrdata:
+ cmd_str = ' '.join(map(lambda x: pipes.quote(x), cmd))
+ msg = "Error messages on '{c}':\n{e}".format(c=cmd_str, e=to_str(stderrdata))
+ if ret_val:
+ self.error_data.append(msg)
+ res = False
+ self.print_out(msg)
+
+ return res
+
# -------------------------------------------------------------------------
def exec_r10k(self):
(ret_val, stdoutdata, stderrdata) = self.handler.call(cmd, sudo=self.do_sudo)
- LOG.debug("Return value: {}".format(ret_val))
if stdoutdata:
msg = "Output:\n{}".format(to_str(stdoutdata))
- LOG.info(msg)
self.print_out(msg)
else:
LOG.debug("No output.")
+
if stderrdata:
+ cmd_str = ' '.join(map(lambda x: pipes.quote(x), cmd))
msg = "Error messages on '{c}':\n{e}".format(c=cmd_str, e=to_str(stderrdata))
if ret_val:
- LOG.warn(msg)
self.error_data.append(msg)
res = False
- else:
- LOG.info(msg)
self.print_out(msg)
return res