Beispiel #1
0
    def __init__(self, project):
        """ Setup Parser Modules
            @project is a relative or absolute path to an Ansible Project
        """
        self.ansiblecfg = AnsibleCfg(project)
        self.roleparser = RoleParser(self.ansiblecfg.get_role_paths())
        self.playbookparser = PlaybookParser(
            self.ansiblecfg.get_playbook_paths())

        # Parse all playbooks
        self.playbookparser.parse_playbooks()
Beispiel #2
0
    def test_ansiblecfg(self):
        localdir = os.path.dirname(os.path.realpath(__file__))
        testfile = os.path.join(localdir, ".output/ansible.cfg")
        with open(testfile, "w") as f:
            f.write("\n roles_path = role1:role2\n")

        ansiblecfg = AnsibleCfg(os.path.dirname(testfile))

        assert("roles_path" in ansiblecfg.settings)

        assert("role1" in ansiblecfg.settings["roles_path"])

        assert("role2" in ansiblecfg.settings["roles_path"])
Beispiel #3
0
    def __init__(self, project):
        """ Setup Parser Modules
            @param project: is a relative or absolute path to an Ansible Project
        """
        self.ansiblecfg = AnsibleCfg(project)
        print("Parsing roles")
        self.roleparser = RoleParser(self.ansiblecfg.get_role_paths())
        print("Parsing playbooks")
        self.playbookparser = PlaybookParser(
            self.ansiblecfg.get_playbook_paths())
        print("Parsing hosts")
        self.hostVarsParser = HostVarsParser(self.ansiblecfg.get_hosts_paths())

        # Parse all playbooks
        self.hostVarsParser.parse_hosts_vars()
        self.playbookparser.parse_playbooks()