def cmd_mkcp(self, target_dir, target): """ return string containing shell commands to create dir and copy a target in there """ target_dir = quote(target_dir) target = quote(target) return f'mkdir -p {target_dir}; cp -vafr {target} {target_dir}'
def prepare(self, how, what): """ add single 'preparator' and run it """ name = 'prepare' cmd = 'provision' # decide what to do if how == 'ansible': name = how self.add_config_block(cmd, name, f'become = true', self.kve('become_user', self.data['user']), self.kve('playbook', what)) # I'm not sure whether this is needed: # run: 'never' else: if self.is_uri(what): method = 'path' else: method = 'inline' self.add_config('vm', cmd, quote(name), self.kv('type', how), self.kv('privileged', 'true'), self.kv('run', 'never'), self.kv(method, what)) return self.run_vagrant(cmd, f'--{cmd}-with', name)
def prepare(self, how, what): """ add single 'preparator' and run it """ name = 'prepare' cmd = 'provision' self.vf_backup("Prepare") # decide what to do if how == 'ansible': name = how # Prepare verbose level based on the --debug option count verbose = self.opt('debug') * 'v' if self.opt('debug') else 'false' self.add_config_block(cmd, name, f'become = true', self.kve('become_user', self.data['user']), self.kve('playbook', what), self.kve('verbose', verbose)) # I'm not sure whether this is needed: # run: 'never' else: if self.is_uri(what): method = 'path' else: method = 'inline' self.add_config('vm', cmd, quote(name), self.kv('type', how), self.kv('privileged', 'true'), self.kv('run', 'never'), self.kv(method, what)) try: self.validate() except GeneralError as error: self.vf_restore() raise GeneralError( f'Invalid input for vagrant prepare ({how}):\n{what}') return self.run_vagrant(cmd, f'--{cmd}-with', name)
def add_synced_folder(self, sync_from, sync_to, *args): """ Add synced_folder entry into Vagrantfile """ self.add_config('vm', 'synced_folder', quote(sync_from), quote(sync_to), self.kv('type', self.sync_type), *args)