pytest-testinfra
pytest-testinfra copied to clipboard
compatibility with molecule/ansible/python
I have testinfra 3.0.5, molecule 2.20.2, anisble 2.8.3. When I run tests, they seem to work only with python 2.7.15.. Otherwise I get this error: ` host = <testinfra.host.Host object at 0x10c816390>
def test_boto3_is_installed(host):
> command = host.command('pip list')
../shared/tests/test_default.py:9:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.7/site-packages/testinfra/modules/command.py:22: in __call__
return self.run(command, *args, **kwargs)
/usr/local/lib/python3.7/site-packages/testinfra/host.py:71: in run
return self.backend.run(command, *args, **kwargs)
/usr/local/lib/python3.7/site-packages/testinfra/backend/ansible.py:46: in run
ssh_identity_file=self.ssh_identity_file)
/usr/local/lib/python3.7/site-packages/testinfra/utils/ansible_runner.py:179: in run
return self.get_host(host, **kwargs).run(command)
/usr/local/lib/python3.7/site-packages/testinfra/host.py:71: in run
return self.backend.run(command, *args, **kwargs)
/usr/local/lib/python3.7/site-packages/testinfra/backend/paramiko.py:117: in run
rc, stdout, stderr = self._exec_command(command)
/usr/local/lib/python3.7/site-packages/testinfra/backend/paramiko.py:104: in _exec_command
chan = self.client.get_transport().open_session()
/usr/local/lib/python3.7/site-packages/testinfra/utils/__init__.py:44: in __get__
value = obj.__dict__[self.func.__name__] = self.func(obj)
/usr/local/lib/python3.7/site-packages/testinfra/backend/paramiko.py:100: in client
client.connect(**cfg)
/usr/local/lib/python3.7/site-packages/paramiko/client.py:334: in connect
to_try = list(self._families_and_addresses(hostname, port))
/usr/local/lib/python3.7/site-packages/paramiko/client.py:204: in _families_and_addresses
hostname, port, socket.AF_UNSPEC, socket.SOCK_STREAM
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
host = 'v-centos7', port = 22, family = <AddressFamily.AF_UNSPEC: 0>
type = <SocketKind.SOCK_STREAM: 1>, proto = 0, flags = 0
def getaddrinfo(host, port, family=0, type=0, proto=0, flags=0):
"""Resolve host and port into list of address info entries.
Translate the host/port argument into a sequence of 5-tuples that contain
all the necessary arguments for creating a socket connected to that service.
host is a domain name, a string representation of an IPv4/v6 address or
None. port is a string service name such as 'http', a numeric port number or
None. By passing None as the value of host and port, you can pass NULL to
the underlying C API.
The family, type and proto arguments can be optionally specified in order to
narrow the list of addresses returned. Passing zero as a value for each of
these arguments selects the full range of results.
"""
# We override this function since we want to translate the numeric family
# and socket type values to enum constants.
addrlist = []
> for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
E socket.gaierror: [Errno 8] nodename nor servname provided, or not known
/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socket.py:748: gaierror
_______________ test_boto3_is_installed[ansible://v-ubuntu1604] ________________
host = <testinfra.host.Host object at 0x10c816160>
def test_boto3_is_installed(host):
> command = host.command('pip list')
../shared/tests/test_default.py:9:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.7/site-packages/testinfra/modules/command.py:22: in __call__
return self.run(command, *args, **kwargs)
/usr/local/lib/python3.7/site-packages/testinfra/host.py:71: in run
return self.backend.run(command, *args, **kwargs)
/usr/local/lib/python3.7/site-packages/testinfra/backend/ansible.py:46: in run
ssh_identity_file=self.ssh_identity_file)
/usr/local/lib/python3.7/site-packages/testinfra/utils/ansible_runner.py:179: in run
return self.get_host(host, **kwargs).run(command)
/usr/local/lib/python3.7/site-packages/testinfra/host.py:71: in run
return self.backend.run(command, *args, **kwargs)
/usr/local/lib/python3.7/site-packages/testinfra/backend/paramiko.py:117: in run
rc, stdout, stderr = self._exec_command(command)
/usr/local/lib/python3.7/site-packages/testinfra/backend/paramiko.py:104: in _exec_command
chan = self.client.get_transport().open_session()
/usr/local/lib/python3.7/site-packages/testinfra/utils/__init__.py:44: in __get__
value = obj.__dict__[self.func.__name__] = self.func(obj)
/usr/local/lib/python3.7/site-packages/testinfra/backend/paramiko.py:100: in client
client.connect(**cfg)
/usr/local/lib/python3.7/site-packages/paramiko/client.py:334: in connect
to_try = list(self._families_and_addresses(hostname, port))
/usr/local/lib/python3.7/site-packages/paramiko/client.py:204: in _families_and_addresses
hostname, port, socket.AF_UNSPEC, socket.SOCK_STREAM
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
` So is there something wrong with the versions compatibility?
Hi, thanks for reporting ! What version of ansible are you using, also can you paste your inventory ? I made some changes to fix various ssh related issues with ansible, the patches are currently on master branch, can you test if this fixes your issue ?