def run_task(self, *args, **kwargs): name = args[1] inventory = ansible.inventory.Inventory( os.path.dirname(os.path.abspath(__file__)) + "/../hosts") env.inventory = inventory env.hosts = inventory.groups_list()[name] task_puts("loading role " + name)
def run_task(self, *args, **kwargs): host_config = env.inventory.get_variables(env.host) hostname = host_config["ssh_host"] if not util.tcping(hostname, 22, 1): task_puts("host {0} does not exist. skip...".format(hostname)) return config = self.get_config( hostname, host_config["ssh_user"], host_config["ssh_pass"], host_config["exec_pass"], host_config["type"] ) self.write_config(env.host, config)
def run_task(self, *args, **kwargs): host_config = env.inventory.get_variables(env.host) hostname = host_config['ssh_host'] if not util.tcping(hostname, 22, 1): task_puts("host {0} does not exist. skip...".format(hostname)) return config = self.get_config(hostname, host_config['ssh_user'], host_config['ssh_pass'], host_config['exec_pass'], host_config['type']) self.write_config(env.host, config)
def run(self, *args, **kwargs): try: env.task_name = task_name = self.__module__.split(".")[-1] + "." + self.name # task_puts(self.name + " start") task_puts("start") self.before_run_task(self, *args, **kwargs) self.run_task(self, *args, **kwargs) self.after_run_task(self, *args, **kwargs) env.task_name = task_name task_puts(green("OK")) except Exception as e: if "fail" not in env or not env.fail: env.fail = True task_puts(red("ERROR:") + " " + str(type(e))) task_puts(red("ERROR:") + " " + str(e)) task_puts(red("NG")) raise
def run(self, *args, **kwargs): try: env.task_name = task_name = self.__module__.split( ".")[-1] + "." + self.name # task_puts(self.name + " start") task_puts("start") self.before_run_task(self, *args, **kwargs) self.run_task(self, *args, **kwargs) self.after_run_task(self, *args, **kwargs) env.task_name = task_name task_puts(green("OK")) except Exception as e: if "fail" not in env or not env.fail: env.fail = True task_puts(red("ERROR:") + " " + str(type(e))) task_puts(red("ERROR:") + " " + str(e)) task_puts(red("NG")) raise
def run_task(self, *args, **kwargs): output_dir = os.path.dirname(os.path.abspath(__file__)) + "/../tmp/config" if self.git_repo_exists(output_dir): with lcd(output_dir): with quiet(): result = local("git diff --exit-code") if not result.failed: task_puts("nothing to commit") else: task_puts("commit config") local("git add -A") local('git commit -m "{0}"'.format(datetime.now().strftime("%Y/%m/%d %H:%M:%S"))) local("git pull --rebase origin master") task_puts("push config") local("git push origin master") else: raise Exception("no git directory")
def run_task(self, *args, **kwargs): output_dir = os.path.dirname( os.path.abspath(__file__)) + "/../tmp/config" if self.git_repo_exists(output_dir): with lcd(output_dir): with quiet(): result = local("git diff --exit-code") if not result.failed: task_puts("nothing to commit") else: task_puts("commit config") local("git add -A") local("git commit -m \"{0}\"".format( datetime.now().strftime("%Y/%m/%d %H:%M:%S"))) local("git pull --rebase origin master") task_puts("push config") local("git push origin master") else: raise Exception("no git directory")
def run_task(self, *args, **kwargs): name = args[1] inventory = ansible.inventory.Inventory(os.path.dirname(os.path.abspath(__file__)) + "/../hosts") env.inventory = inventory env.hosts = inventory.groups_list()[name] task_puts("loading role " + name)
def run_task(self, *args, **kwargs): output['running'] = True output['output'] = True task_puts(green("enable debug output"))