Esempio n. 1
0
    def execute(self):
        """
        Execute the actions necessary to perform a `molecule lint` and \
        returns None.

        :return: None
        """
        self.print_info()

        # v3 migration code:
        cmd = self._config.lint
        if not cmd:
            LOG.info("Lint is disabled.")
            return

        if cmd == 'yamllint':
            msg = (
                "Deprecated linter config found, migrate to v3 schema. "
                "See https://github.com/ansible-community/molecule/issues/2293"
            )
            util.sysexit_with_message(msg)

        try:
            LOG.info("Executing: %s" % cmd)
            util.run(cmd, shell=True, universal_newlines=True, check=True)
        except Exception as e:
            util.sysexit_with_message("Lint failed: %s: %s" % (e, e))
Esempio n. 2
0
def supports_podman():
    # Returns true if podman is supported and working
    # Returns false if podman in not supported
    # Calls pytest.fail if podman appears to be broken
    podman = get_podman_executable()
    if not min_ansible("2.8.6") or platform.system() == "Darwin" or not podman:
        return False

    result = util.run([podman, "info"], stdout=PIPE, universal_newlines=True)
    if result.returncode != 0:
        LOG.error(
            "Error %s returned from `podman info`: %s",
            result.returncode,
            result.stdout,
        )
        pytest.fail(
            "Cannot run podman tests with a broken podman installation.")
        return False

    # checks for minimal version of podman
    cmd = ["podman", "version", "-f", "{{.Version}}"]
    podman_version = util.check_output(cmd,
                                       stderr=subprocess.STDOUT,
                                       universal_newlines=True)
    # We need to use the outdated LooseVersion because podman versioning
    # is not PEP-440 compliant, example '1.4.2-stable3' which should evaluate
    # as newer than '1.4.2'
    if LooseVersion(podman_version) < LooseVersion(MIN_PODMAN_VERSION):
        pytest.fail(
            "Podman driver requires version >={}, and you have {}".format(
                MIN_PODMAN_VERSION, podman_version))

    return True
Esempio n. 3
0
def supports_docker():
    docker = get_docker_executable()
    if docker:
        result = util.run([docker, "info"], stdout=PIPE, universal_newlines=True)
        if result.returncode != 0:
            LOG.error(
                "Error %s returned from `docker info`: %s",
                result.returncode,
                result.stdout,
            )
            return False
        if "BuildahVersion" in result.stdout:
            LOG.error(
                "podman-docker is unsupported, see https://github.com/ansible-community/molecule/issues/2456"
            )
            return False
    return True
Esempio n. 4
0
def supports_podman():
    # Returns true if podman is supported and working
    # Returns false if podman in not supported
    # Calls pytest.fail if podman appears to be broken
    podman = get_podman_executable()
    if not min_ansible("2.8.6") or platform.system() == 'Darwin' or not podman:
        return False

    result = util.run([podman, "info"], stdout=PIPE, universal_newlines=True)
    if result.returncode != 0:
        LOG.error(
            "Error %s returned from `podman info`: %s",
            result.returncode,
            result.stdout,
        )
        pytest.fail(
            "Cannot run podman tests with a broken podman installation.")
        return False

    return True