def package(path, role, exclude): print "generating", path paths = ["./%s" % srcpath for srcpath in get_source_paths( role = role, exclude = exclude)] argv = ["tar", "-vczf", os.path.abspath(path)] + paths fckit.check_call(*argv)
def package(path, role, exclude): print "generating", path paths = [ "./%s" % srcpath for srcpath in get_source_paths(role=role, exclude=exclude) ] argv = ["tar", "-vczf", os.path.abspath(path)] + paths fckit.check_call(*argv)
def _check_call(self, args): prefs = self.preferences.get(args[0], {}) args = list(args) args[0] = prefs.get("path", args[0]) argslist = prefs.get("before", []) + [args + prefs.get("append", [])] + prefs.get("after", []) for args in argslist: args[0] = fckit.Path(args[0]) fckit.check_call(*args)
def check_syntax(role, helpers): "generate a playbook using the role and syntax-check it" tmpdir = fckit.mkdir() cwd = os.getcwd() #print "!! role path=", cwd #print "!! playbook path=", tmpdir fckit.chdir(tmpdir) try: # write playbook: playbook = [{ "hosts": "127.0.0.1", "connection": "local", "roles": [role.name], }] helpers["marshall"]( obj = playbook, path = os.path.join(tmpdir, "playbook.yml")) # write inventory: inventory = "localhost ansible_connection=local" helpers["marshall"]( obj = inventory, path = os.path.join(tmpdir, "inventory.cfg"), extname = ".txt") # write configuration: config = { "defaults": { "roles_path": os.path.dirname(cwd), "hostfile": "inventory.cfg", } } helpers["marshall"]( obj = config, path = os.path.join(tmpdir, "ansible.cfg")) # perform the check: fckit.check_call("ansible-playbook", "playbook.yml", "--syntax-check") return True except: return False finally: fckit.chdir(cwd) fckit.remove(tmpdir)
def check_syntax(role, helpers): "generate a playbook using the role and syntax-check it" tmpdir = fckit.mkdir() cwd = os.getcwd() #print "!! role path=", cwd #print "!! playbook path=", tmpdir fckit.chdir(tmpdir) try: # write playbook: playbook = [{ "hosts": "127.0.0.1", "connection": "local", "roles": [role.name], }] helpers["marshall"](obj=playbook, path=os.path.join(tmpdir, "playbook.yml")) # write inventory: inventory = "localhost ansible_connection=local" helpers["marshall"](obj=inventory, path=os.path.join(tmpdir, "inventory.cfg"), extname=".txt") # write configuration: config = { "defaults": { "roles_path": os.path.dirname(cwd), "hostfile": "inventory.cfg", } } helpers["marshall"](obj=config, path=os.path.join(tmpdir, "ansible.cfg")) # perform the check: fckit.check_call("ansible-playbook", "playbook.yml", "--syntax-check") return True except: return False finally: fckit.chdir(cwd) fckit.remove(tmpdir)
def publish(path, url): print "publishing", path, "to", url fckit.check_call("curl", "-k", "-T", path, url)
def publish(path, url): fckit.check_call("curl", "-k", "-T", path, url)
def package(role): if not os.path.exists(role.dist_path): fckit.mkdir(role.dist_path) fckit.check_call("tar", "czf", role.package_path, "--exclude", role.dist_path, ".")