Exemplo n.º 1
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.º 2
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.º 3
0
def trailing_instance(molecule_instance):
    return trailing.Trailing(molecule_instance)