コード例 #1
0
 def test(self):
     role = universe.Role()
     fckit.mkdir("meta")
     galaxy_info = {"author": "John Doe"}
     manifest = {
         "version": 42,
         "galaxy_info": galaxy_info,
     }
     universe.marshall(obj=manifest, path=role.meta_path)
     self.assertEqual(role.name, os.path.basename(self.tmpdir))
     self.assertEqual(role.get_manifest(), manifest)
     self.assertEqual(role.version, 42)
     self.assertEqual(role.galaxy_info, galaxy_info)
     self.assertEqual(role.author, galaxy_info["author"])
コード例 #2
0
ファイル: test.py プロジェクト: fclaerho/buildstack
	def setUp(self):
		# generate build manifest
		self.dirname = fckit.mkdir()
		with open(os.path.join(self.dirname, "Foobuild"), "w") as fp:
			fp.write(FOOBUILD)
		self.buildstack = buildstack.BuildStack(
			manifests = (MANIFEST,),
			path = self.dirname)
コード例 #3
0
ファイル: test.py プロジェクト: Leenie/ansible-universe
	def test(self):
		role = universe.Role()
		fckit.mkdir("meta")
		galaxy_info = {
			"author": "John Doe"
		}
		manifest = {
			"version": 42,
			"galaxy_info": galaxy_info,
		}
		universe.marshall(
			obj = manifest,
			path = role.meta_path)
		self.assertEqual(role.name, os.path.basename(self.tmpdir))
		self.assertEqual(role.get_manifest(), manifest)
		self.assertEqual(role.version, 42)
		self.assertEqual(role.galaxy_info, galaxy_info)
		self.assertEqual(role.author, galaxy_info["author"])
コード例 #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
ファイル: test.py プロジェクト: pombredanne/ansible-universe
	def setUp(self):
		self.tmpdir = fckit.mkdir()
		self._main("init")
コード例 #7
0
 def setUp(self):
     self.cwd = os.getcwd()
     self.tmpdir = fckit.mkdir()
コード例 #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
ファイル: test.py プロジェクト: Leenie/ansible-universe
	def setUp(self):
		self.cwd = os.getcwd()
		self.tmpdir = fckit.mkdir()