Exemple #1
0
    def _set_up_hieradata(self, hieradata):
        import tarfile
        import shutil

        if tarfile.is_tarfile(hieradata):
            tar = tarfile.open(hieradata,'r:gz')

            dest_dir = os.path.join(self._distro._mountpoint,'etc','puppet')

            mkdir_p(dest_dir)
            log.debug('Untarring {0} to {1}'.format(hieradata, dest_dir))
            tar.extractall(dest_dir)
            tar.close

            self._list_files(self._distro._mountpoint + '/etc/puppet/hieradata')
        else:
            log.debug('Hieradata file \'{0}\' is not a tarball.', format(hieradata))
Exemple #2
0
    def _set_up_puppet_certs(self, pem_file_name):
        certs_dir = self._get_config_value('puppet_certs_dir')
        private_keys_dir = self._get_config_value('puppet_private_keys_dir')

        mkdir_p(self._distro._mountpoint + certs_dir)
        mkdir_p(self._distro._mountpoint + private_keys_dir)

        cert = os.path.join(certs_dir,pem_file_name + '.pem')
        key = os.path.join(private_keys_dir, pem_file_name + '.pem')

        if not os.access( cert, os.F_OK ):
            generate_certificate(self._config.context.package.arg)

        log.debug('Placing certs for {0} into mountpoint {1}'.format(pem_file_name, self._distro._mountpoint))
        shutil.copy(os.path.join(certs_dir, 'ca.pem'),              self._distro._mountpoint + certs_dir)
        shutil.copy(cert , self._distro._mountpoint + certs_dir)
        shutil.copy(key, self._distro._mountpoint + private_keys_dir)
Exemple #3
0
    def __init__(self,
                 config=None,
                 parser=None,
                 plugin_manager=PluginManager,
                 environment=Environment,
                 debug=False,
                 envname=None):
        log.info('Aminator starting...')
        if not all((config, parser)):
            log.debug('Loading default configuration')
            config, parser = init_defaults(debug=debug)
        self.config = config
        self.parser = parser
        log.debug('Configuration loaded')
        if not envname:
            envname = self.config.environments.default
        self.plugin_manager = plugin_manager(
            self.config,
            self.parser,
            plugins=self.config.environments[envname])
        log.debug('Plugins loaded')
        self.parser.parse_args()
        log.debug('Args parsed')

        log.debug('Creating initial folder structure if needed')
        mkdir_p(self.config.log_root)
        mkdir_p(os.path.join(self.config.aminator_root, self.config.lock_dir))
        mkdir_p(os.path.join(self.config.aminator_root,
                             self.config.volume_dir))

        if self.config.logging.aminator.enabled:
            log.debug('Configuring per-package logging')
            configure_datetime_logfile(self.config, 'aminator')

        self.environment = environment()
Exemple #4
0
    def __init__(self, config=None, parser=None, plugin_manager=PluginManager, environment=Environment, debug=False, envname=None):
        log.info('Aminator starting...')
        if not all((config, parser)):
            log.debug('Loading default configuration')
            config, parser = init_defaults(debug=debug)
        self.config = config
        self.parser = parser
        log.debug('Configuration loaded')
        if not envname:
            envname = self.config.environments.default
        self.plugin_manager = plugin_manager(self.config, self.parser, plugins=self.config.environments[envname])
        log.debug('Plugins loaded')
        self.parser.parse_args()
        log.debug('Args parsed')

        log.debug('Creating initial folder structure if needed')
        mkdir_p(self.config.log_root)
        mkdir_p(os.path.join(self.config.aminator_root, self.config.lock_dir))
        mkdir_p(os.path.join(self.config.aminator_root, self.config.volume_dir))

        if self.config.logging.aminator.enabled:
            log.debug('Configuring per-package logging')
            configure_datetime_logfile(self.config, 'aminator')

        self.environment = environment()
Exemple #5
0
    def _set_up_puppet_manifests(self, manifests):
        import tarfile
        import shutil

        if tarfile.is_tarfile(manifests):
            self._puppet_apply_file = ''
            tar = tarfile.open(manifests,'r:gz')

            dest_dir = os.path.join(self._distro._mountpoint,'etc','puppet') if 'modules' in tar.getnames() else os.path.join(self._distro._mountpoint,'etc','puppet','modules')

            mkdir_p(dest_dir)
            log.debug('Untarring to {0}'.format(dest_dir))
            tar.extractall(dest_dir)
            tar.close

            self._list_files(self._distro._mountpoint + '/etc/puppet')

        else:
            self._puppet_apply_file = os.path.join('etc','puppet','modules', os.path.basename(manifests))
            dest_file = os.path.join(self._distro._mountpoint,'etc','puppet','modules', os.path.basename(manifests))
            mkdir_p(os.path.join(self._distro._mountpoint,'etc','puppet','modules'))
            log.debug('Trying to copy \'{0}\' to \'{1}\''.format(manifests, dest_file))
            shutil.copy2(manifests, dest_file)
 def _save_image_cache(self, filename, details):
     cache_dir = os.path.join(self._config.aminator_root, "image-cache")
     cache_file = os.path.join(cache_dir, filename)
     mkdir_p(cache_dir)
     with open(cache_file, 'w') as f:
         dill.dump(details, f)
Exemple #7
0
 def _save_image_cache(self, filename, details):
     cache_dir = os.path.join(self._config.aminator_root, "image-cache")
     cache_file = os.path.join(cache_dir, filename)
     mkdir_p(cache_dir)
     with open(cache_file, 'w') as f:
         dill.dump(details, f)