Skip to content

Commit

Permalink
Avoid running docker tests with podman-docker (#2457)
Browse files Browse the repository at this point in the history
Relates: #2456

Signed-off-by: Sorin Sbarnea <[email protected]>
  • Loading branch information
ssbarnea authored and sshnaidm committed Dec 7, 2019
1 parent ef22d5d commit b94c527
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
11 changes: 2 additions & 9 deletions molecule/command/init/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,14 @@
# DEALINGS IN THE SOFTWARE.

import os
import sys
import click
import subprocess
from molecule import api
from molecule import logger
from molecule import util
from molecule.command import base as command_base
from molecule.command.init import base

if os.name == 'posix' and sys.version_info[0] < 3:
import subprocess32 as subprocess
else:
import subprocess


LOG = logger.get_logger(__name__)

Expand Down Expand Up @@ -77,9 +72,7 @@ def execute(self):

try:
cmd = ["ansible-galaxy", "init", "-v", "--offline", role_name]
subprocess.check_output(
cmd, stderr=subprocess.STDOUT, universal_newlines=True
)
util.check_output(cmd, stderr=subprocess.STDOUT, universal_newlines=True)
except Exception as e:
util.sysexit_with_message(
"Galaxy failed to create role: %s: %s" % (e, e.output)
Expand Down
18 changes: 17 additions & 1 deletion molecule/test/functional/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import pexpect
import pytest
import sh
from subprocess import PIPE

from molecule import logger
from molecule import util
Expand Down Expand Up @@ -246,7 +247,22 @@ def get_virtualbox_executable():

@pytest.helpers.register
def supports_docker():
return get_docker_executable()
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/molecule/issues/2456"
)
return False
return True


def min_ansible(version):
Expand Down
7 changes: 7 additions & 0 deletions molecule/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
import re
import sys

try:
from subprocess import check_output # noqa 401
from subprocess import run # noqa 401
except ImportError:
from subprocess32 import check_output # noqa 401
from subprocess32 import run # noqa 401

try:
from collections.abc import Mapping
except ImportError: # Python 2 compatibility
Expand Down

0 comments on commit b94c527

Please sign in to comment.