Exemplo n.º 1
0
def molecule_verifiers():
    return [
        goss.Goss(None).name,
        inspec.Inspec(None).name,
        testinfra.Testinfra(None).name,
        ansible_verifier.Ansible(None).name,
    ]
Exemplo n.º 2
0
    def execute(self, exit=True):
        """
        Execute the actions necessary to perform a `molecule verify` and
        return a tuple.

        :param exit: An optional flag to toggle the exiting of the module
         on command failure.
        :return: Return a tuple of None, otherwise sys.exit on command failure.
        """
        for v in [ansible_lint.AnsibleLint(self.molecule),
                  trailing.Trailing(self.molecule)]:
            v.execute()

        self.molecule.write_ssh_config()

        try:
            if self.molecule.verifier == 'serverspec':
                v = serverspec.Serverspec(self.molecule)
            elif self.molecule.verifier == 'goss':
                v = goss.Goss(self.molecule)
            else:
                v = testinfra.Testinfra(self.molecule)

            v.execute()
        except sh.ErrorReturnCode as e:
            LOG.error('ERROR: {}'.format(e))
            if exit:
                util.sysexit(e.exit_code)
            return e.exit_code, e.stdout

        return None, None
Exemplo n.º 3
0
 def verifier(self):
     verifier_name = self.config['verifier']['name']
     if verifier_name == 'testinfra':
         return testinfra.Testinfra(self)
     elif verifier_name == 'inspec':
         return inspec.Inspec(self)
     elif verifier_name == 'goss':
         return goss.Goss(self)
Exemplo n.º 4
0
 def verifier(self):
     verifier_name = self.config['verifier']['name']
     if verifier_name == 'testinfra':
         return testinfra.Testinfra(self)
     elif verifier_name == 'goss':
         return goss.Goss(self)
     else:
         util.exit_with_invalid_section('verifier', verifier_name)
Exemplo n.º 5
0
    def execute(self, exit=True):
        tw = trailing.Trailing(self.molecule)
        tw.execute()

        self.molecule._write_ssh_config()

        try:
            ti = testinfra.Testinfra(self.molecule)
            ti.execute()

            ss = serverspec.Serverspec(self.molecule)
            ss.execute()
        except sh.ErrorReturnCode as e:
            LOG.error('ERROR: {}'.format(e))
            if exit:
                util.sysexit(e.exit_code)
            return e.exit_code, e.stdout

        return None, None
Exemplo n.º 6
0
def _instance(patched_config_validate, config_instance):
    return testinfra.Testinfra(config_instance)
Exemplo n.º 7
0
def testinfra_instance(molecule_instance):
    return testinfra.Testinfra(molecule_instance)
Exemplo n.º 8
0
def molecule_verifiers():
    return [goss.Goss(None).name, testinfra.Testinfra(None).name]
Exemplo n.º 9
0
def testinfra_instance(molecule_verifier_section_data, config_instance):
    config_instance.merge_dicts(config_instance.config,
                                molecule_verifier_section_data)

    return testinfra.Testinfra(config_instance)