def on_vars_prompt(self, varname, private=True, prompt=None, encrypt=None, confirm=False, salt_size=None, salt=None, default=None): callbacks.call_callback_module('playbook_on_vars_prompt', varname, private=private, prompt=prompt, encrypt=encrypt, confirm=confirm, salt_size=salt_size, salt=None, default=default)
def on_vars_prompt(self, varname, private=True, prompt=None, encrypt=None, confirm=False, salt_size=None, salt=None, default=None): if prompt and default is not None: msg = "%s [%s]: " % (prompt, default) elif prompt: msg = "%s: " % prompt else: msg = 'input for %s: ' % varname def do_prompt(prompt, private): if sys.stdout.encoding: msg = prompt.encode(sys.stdout.encoding) else: # when piping the output, or at other times when stdout # may not be the standard file descriptor, the stdout # encoding may not be set, so default to something sane msg = prompt.encode(locale.getpreferredencoding()) if private: return getpass.getpass(msg) return raw_input(msg) if confirm: while True: result = do_prompt(msg, private) second = do_prompt("confirm " + msg, private) if result == second: break display("***** VALUES ENTERED DO NOT MATCH ****", task_id=self.task_id) else: result = do_prompt(msg, private) # if result is false and default is not None if not result and default is not None: result = default if encrypt: result = utils.do_encrypt(result, encrypt, salt_size, salt) # handle utf-8 chars result = to_unicode(result, errors='strict') call_callback_module('playbook_on_vars_prompt', varname, private=private, prompt=prompt, encrypt=encrypt, confirm=confirm, salt_size=salt_size, salt=None, default=default) return result
def on_task_start(self, name, is_conditional): if hasattr(self, 'step') and self.step: resp = raw_input('Perform task: %s (y/n/c): ' % name) if resp.lower() in ['y', 'yes']: self.skip_task = False elif resp.lower() in ['c', 'continue']: self.skip_task = False self.step = False else: self.skip_task = True call_callback_module('playbook_on_task_start', name, is_conditional)
def on_task_start(self, name, is_conditional): if hasattr(self, 'step') and self.step: resp = raw_input('Perform task: %s (y/n/c): ' % name) if resp.lower() in ['y', 'yes']: self.skip_task = False elif resp.lower() in ['c', 'continue']: self.skip_task = False self.step = False else: self.skip_task = True anscb.call_callback_module('playbook_on_task_start', name, is_conditional)
def on_task_start(self, name, is_conditional): if hasattr(self, "step") and self.step: resp = raw_input("Perform task: %s (y/n/c): " % name) if resp.lower() in ["y", "yes"]: self.skip_task = False elif resp.lower() in ["c", "continue"]: self.skip_task = False self.step = False else: self.skip_task = True call_callback_module("playbook_on_task_start", name, is_conditional)
def on_vars_prompt(self, varname, private=True, prompt=None, encrypt=None, confirm=False, salt_size=None, salt=None, default=None): if prompt and default is not None: msg = "%s [%s]: " % (prompt, default) elif prompt: msg = "%s: " % prompt else: msg = 'input for %s: ' % varname def do_prompt(prompt, private): if sys.stdout.encoding: msg = prompt.encode(sys.stdout.encoding) else: # when piping the output, or at other times when stdout # may not be the standard file descriptor, the stdout # encoding may not be set, so default to something sane msg = prompt.encode(locale.getpreferredencoding()) if private: return getpass.getpass(msg) return raw_input(msg) if confirm: while True: result = do_prompt(msg, private) second = do_prompt("confirm " + msg, private) if result == second: break display("***** VALUES ENTERED DO NOT MATCH ****", task_id=self.task_id) else: result = do_prompt(msg, private) # if result is false and default is not None if not result and default is not None: result = default if encrypt: result = utils.do_encrypt(result, encrypt, salt_size, salt) # handle utf-8 chars result = to_unicode(result, errors='strict') call_callback_module('playbook_on_vars_prompt', varname, private=private, prompt=prompt, encrypt=encrypt, confirm=confirm, salt_size=salt_size, salt=None, default=default ) return result
def on_task_start(self, name, is_conditional): name = utils.unicode.to_bytes(name) msg = "TASK: [%s]" % name if is_conditional: msg = "NOTIFIED: [%s]" % name if hasattr(self, 'start_at'): self.start_at = utils.unicode.to_bytes(self.start_at) if name == self.start_at or fnmatch.fnmatch(name, self.start_at): # we found out match, we can get rid of this now del self.start_at elif self.task.role_name: # handle tasks prefixed with rolenames actual_name = name.split('|', 1)[1].lstrip() if actual_name == self.start_at or fnmatch.fnmatch( actual_name, self.start_at): del self.start_at if hasattr(self, 'start_at'): # we still have start_at so skip the task self.skip_task = True elif hasattr(self, 'step') and self.step: if isinstance(name, str): name = utils.unicode.to_unicode(name) msg = u'Perform task: %s (y/n/c): ' % name if sys.stdout.encoding: msg = to_bytes(msg, sys.stdout.encoding) else: msg = to_bytes(msg) resp = raw_input(msg) if resp.lower() in ['y', 'yes']: self.skip_task = False display(banner(msg), task_id=self.task_id) elif resp.lower() in ['c', 'continue']: self.skip_task = False self.step = False display(banner(msg), task_id=self.task_id) else: self.skip_task = True else: self.skip_task = False display(banner(msg), task_id=self.task_id) call_callback_module('playbook_on_task_start', name, is_conditional)
def on_task_start(self, name, is_conditional): name = utils.unicode.to_bytes(name) msg = "TASK: [%s]" % name if is_conditional: msg = "NOTIFIED: [%s]" % name if hasattr(self, 'start_at'): self.start_at = utils.unicode.to_bytes(self.start_at) if name == self.start_at or fnmatch.fnmatch(name, self.start_at): # we found out match, we can get rid of this now del self.start_at elif self.task.role_name: # handle tasks prefixed with rolenames actual_name = name.split('|', 1)[1].lstrip() if actual_name == self.start_at or fnmatch.fnmatch(actual_name, self.start_at): del self.start_at if hasattr(self, 'start_at'): # we still have start_at so skip the task self.skip_task = True elif hasattr(self, 'step') and self.step: if isinstance(name, str): name = utils.unicode.to_unicode(name) msg = u'Perform task: %s (y/n/c): ' % name if sys.stdout.encoding: msg = to_bytes(msg, sys.stdout.encoding) else: msg = to_bytes(msg) resp = raw_input(msg) if resp.lower() in ['y', 'yes']: self.skip_task = False display(banner(msg), task_id=self.task_id) elif resp.lower() in ['c', 'continue']: self.skip_task = False self.step = False display(banner(msg), task_id=self.task_id) else: self.skip_task = True else: self.skip_task = False display(banner(msg), task_id=self.task_id) call_callback_module('playbook_on_task_start', name, is_conditional)
def on_import_for_host(self, host, imported_file): callbacks.call_callback_module('playbook_on_import_for_host', host, imported_file)
def on_notify(self, host, handler): callbacks.call_callback_module('playbook_on_notify', host, handler)
def on_no_hosts_remaining(self): callbacks.call_callback_module('playbook_on_no_hosts_remaining')
def on_play_start(self, name): callbacks.call_callback_module('playbook_on_play_start', name)
def on_play_start(self, pattern): display(banner("Executing playbook %s" % self.playbook.filename), color="bright blue") call_callback_module('playbook_on_play_start', pattern)
def on_play_start(self, pattern): call_callback_module("playbook_on_play_start", pattern)
def on_no_hosts_remaining(self): display("\nFATAL: all hosts have already failed -- aborting", color='red', task_id=self.task_id) call_callback_module('playbook_on_no_hosts_remaining')
def on_import_for_host(self, host, imported_file): call_callback_module("playbook_on_import_for_host", host, imported_file)
def on_not_import_for_host(self, host, missing_file): call_callback_module("playbook_on_not_import_for_host", host, missing_file)
def on_setup(self): call_callback_module("playbook_on_setup")
def on_not_import_for_host(self, host, missing_file): msg = "%s: not importing file: %s" % (host, missing_file) display(msg, color='cyan', task_id=self.task_id) call_callback_module('playbook_on_not_import_for_host', host, missing_file)
def on_no_hosts_remaining(self): call_callback_module("playbook_on_no_hosts_remaining")
def on_no_hosts_matched(self): call_callback_module("playbook_on_no_hosts_matched")
def on_stats(self, stats): call_callback_module("playbook_on_stats", stats)
def on_play_start(self, pattern): anscb.call_callback_module('playbook_on_play_start', pattern)
def on_import_for_host(self, host, imported_file): msg = "%s: importing %s" % (host, imported_file) display(msg, color='cyan', task_id=self.task_id) call_callback_module('playbook_on_import_for_host', host, imported_file)
def on_task_start(self, name, is_conditional): callbacks.call_callback_module('playbook_on_task_start', name, is_conditional) if self.cancel_event and self.cancel_event.is_set(): raise ValidationCancelled()
def on_no_hosts_matched(self): display("skipping: no hosts matched", color='cyan', task_id=self.task_id) call_callback_module('playbook_on_no_hosts_matched')
def on_no_hosts_remaining(self): display("\tFailed playbook: %s" % self.playbook.filename, color='bright red') call_callback_module('playbook_on_no_hosts_remaining')
def on_start(self): callbacks.call_callback_module('playbook_on_start')
def on_play_start(self, pattern): callbacks.call_callback_module('playbook_on_play_start', pattern)
def on_no_hosts_matched(self): callbacks.call_callback_module('playbook_on_no_hosts_matched')
def on_no_hosts_matched(self): anscb.call_callback_module('playbook_on_no_hosts_matched')
def on_task_start(self, name, is_conditional): callbacks.call_callback_module('playbook_on_task_start', name, is_conditional)
def on_setup(self): display(banner("GATHERING FACTS"), task_id=self.task_id) call_callback_module('playbook_on_setup')
def on_setup(self): callbacks.call_callback_module('playbook_on_setup')
def on_import_for_host(self, host, imported_file): anscb.call_callback_module('playbook_on_import_for_host', host, imported_file)
def on_not_import_for_host(self, host, missing_file): callbacks.call_callback_module('playbook_on_not_import_for_host', host, missing_file)
def on_play_start(self, name): display(banner("PLAY [%s]" % name), task_id=self.task_id) call_callback_module('playbook_on_play_start', name)
def on_stats(self, stats): callbacks.call_callback_module('playbook_on_stats', stats)
def on_no_hosts_remaining(self): anscb.call_callback_module('playbook_on_no_hosts_remaining')
def on_setup(self): anscb.call_callback_module('playbook_on_setup')
def on_not_import_for_host(self, host, missing_file): anscb.call_callback_module('playbook_on_not_import_for_host', host, missing_file)
def on_stats(self, stats): anscb.call_callback_module('playbook_on_stats', stats)