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"])
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)
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"])
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 setUp(self): self.tmpdir = fckit.mkdir() self._main("init")
def setUp(self): self.cwd = os.getcwd() self.tmpdir = fckit.mkdir()
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, ".")