def provision_single(self, guest):
""" Performs the provisioning operations using puppet. """
# Verify if `puppet` has been installed.
binary_path = self.options.get('binary_path')
if binary_path is not None:
puppet_bin = str(PurePosixPath(binary_path) / 'puppet')
retcode = guest.run(['test', '-x', puppet_bin])
fail_msg = (
"puppet executable is not found in the specified path {} in the "
"guest container. ".format(binary_path)
)
else:
retcode = guest.run(['which', 'puppet'])
fail_msg = (
"puppet was not automatically installed for this guest. "
"Please specify the command to install it in LXDock file using "
"a shell provisioner and try `lxdock provision` again. You may "
"also specify `binary_path` that contains the puppet executable "
"in LXDock file.")
if retcode != 0:
raise ProvisionFailed(fail_msg)
# Copy manifests dir
manifests_path = self.options.get('manifests_path')
if manifests_path is not None:
guest.copy_directory(
Path(manifests_path), PurePosixPath(self._guest_manifests_path))
# Copy module dir
module_path = self.options.get('module_path')
if module_path is not None:
guest.copy_directory(Path(module_path), PurePosixPath(self._guest_module_path))
# Copy environment dir
environment_path = self.options.get('environment_path')
if environment_path is not None:
guest.copy_directory(
Path(environment_path), PurePosixPath(self._guest_environment_path))
# Copy hiera file
hiera_file = self.options.get('hiera_config_path')
if hiera_file is not None:
guest.copy_file(Path(hiera_file), PurePosixPath(self._guest_hiera_file))
# Run puppet.
command = self._build_puppet_command()
if environment_path:
logger.info("Running Puppet with environment {}...".format(self.options['environment']))
else:
logger.info("Running Puppet with {}...".format(self.options['manifest_file']))
guest.run(['sh', '-c', ' '.join(command)])
##################################
# PRIVATE METHODS AND PROPERTIES #
##################################
评论列表
文章目录