def _install(self, bootstrap_url, bootstrap_file = 'bootstrap.sh'): """ Installs saltstack using bootstrap url """ tmp_dir = mkdtemp() bootstrap_file = tmp_dir + '/' + bootstrap_file ecm.download_file(bootstrap_url, bootstrap_file) # wget -O - http://bootstrap.saltstack.org | sudo sh # Options: #-h Display this message #-v Display script version #-n No colours. #-D Show debug output. #-c Temporary configuration directory #-g Salt repository URL. (default: git://github.com/saltstack/salt.git) #-k Temporary directory holding the minion keys which will pre-seed the master. #-M Also install salt-master #-S Also install salt-syndic #-N Do not install salt-minion #-X Do not start daemons after installation #-C Only run the configuration function. This option automatically bypasses any installation. #-P Allow pip based installations. On some distributions the required salt packages or its dependencies are not available as a package for that distribution. Using this flag allows the script to use pip as a last resort method. NOTE: This works for functions which actually implement pip based installations. #-F Allow copied files to overwrite existing(config, init.d, etc) #-U If set, fully upgrade the system prior to bootstrapping salt #-K If set, keep the temporary files in the temporary directories specified with -c and -k. if ecm.file_read(bootstrap_file): envars = {'DEBIAN_FRONTEND': 'noninteractive'} ecm.run_file(bootstrap_file, args=['-n', '-P', '-X'], envars=envars) rmtree(tmp_dir) return bool(self._is_available())
def _install(self, bootstrap_url, bootstrap_file = 'bootstrap.sh'): """ Installs puppet using bootstrap url """ tmp_dir = mkdtemp() bootstrap_file = tmp_dir + '/' + bootstrap_file ecm.download_file(bootstrap_url, bootstrap_file) # wget -O - http://bootstrap.ecmanaged.com/puppet/linux/ | sudo sh if ecm.file_read(bootstrap_file): envars = {'DEBIAN_FRONTEND': 'noninteractive'} ecm.run_file(bootstrap_file, envars=envars) rmtree(tmp_dir) return bool(self._is_available())
def cmd_script_run(self, *argv, **kwargs): """ run script(b64) extension envars runas executable Syntax: script.run[script,extenion,envars,facts,runas,executable] """ script_b64 = kwargs.get('script', None) script_extension = kwargs.get('extension', None) script_runas = kwargs.get('runas', None) script_executable = kwargs.get('executable', None) metadata = kwargs.get('metadata', None) if not script_extension: script_extension = '.cmd' if not script_b64: raise ecm.InvalidParameters(self.cmd_script_run.__doc__) try: # Write down tmp_dir = mkdtemp() tmp_file = tmp_dir + '/script' + script_extension ecm.file_write(tmp_file, b64decode(script_b64)) except: raise ecm.InvalidParameters("Unable to decode b64") # Set environment variables before execution envars = ecm.metadata_to_env(metadata_b64=metadata) # Update metadata ecm.write_metadata(metadata_b64=metadata) # Chown if script_runas: ecm.chown(tmp_dir,script_runas,recursive=True) if script_executable: cmd = script_executable + ' ' + tmp_file out, stdout, stderr = ecm.run_command(cmd, runas=script_runas, workdir=tmp_dir, envars=envars) else: out, stdout, stderr = ecm.run_file(tmp_file, runas=script_runas, workdir=tmp_dir, envars=envars) rmtree(tmp_dir, ignore_errors=True) return ecm.format_output(out, stdout, stderr)