Пример #1
0
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)
Пример #2
0
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)
Пример #3
0
	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)
Пример #4
0
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)
Пример #5
0
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)
Пример #6
0
def publish(path, url):
	print "publishing", path, "to", url
	fckit.check_call("curl", "-k", "-T", path, url)
Пример #7
0
def publish(path, url):
	fckit.check_call("curl", "-k", "-T", path, url)
Пример #8
0
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, ".")
Пример #9
0
def publish(path, url):
    print "publishing", path, "to", url
    fckit.check_call("curl", "-k", "-T", path, url)