Hello community,
here is the log from the commit of package python-testinfra for
openSUSE:Factory checked in at 2019-09-17 13:39:08
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-testinfra (Old)
and /work/SRC/openSUSE:Factory/.python-testinfra.new.7948 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-testinfra"
Tue Sep 17 13:39:08 2019 rev:11 rq:731296 version:3.2.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-testinfra/python-testinfra.changes
2019-09-04 09:10:37.726977459 +0200
+++
/work/SRC/openSUSE:Factory/.python-testinfra.new.7948/python-testinfra.changes
2019-09-17 13:39:10.581825953 +0200
@@ -1,0 +2,10 @@
+Mon Sep 16 13:27:28 UTC 2019 - Tomáš Chvátal <[email protected]>
+
+- Update to 3.2.0:
+ * New module "environment" for getting remote environment variables
+ * New module "block_device" exposing block device informations
+ * Add a global flag --force-ansible to the command line
+ * Raise an error in case of missing ansible inventory file
+ * Fix an escape issue with ansible ssh args set inventory or configuration
file
+
+-------------------------------------------------------------------
Old:
----
testinfra-3.1.0.tar.gz
New:
----
testinfra-3.2.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-testinfra.spec ++++++
--- /var/tmp/diff_new_pack.8bmyyC/_old 2019-09-17 13:39:11.085825872 +0200
+++ /var/tmp/diff_new_pack.8bmyyC/_new 2019-09-17 13:39:11.085825872 +0200
@@ -18,12 +18,12 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-testinfra
-Version: 3.1.0
+Version: 3.2.0
Release: 0
Summary: Python module to test infrastructures
License: Apache-2.0
Group: Development/Languages/Python
-URL: http://github.com/philpep/testinfra
+URL: https://github.com/philpep/testinfra
Source:
https://files.pythonhosted.org/packages/source/t/testinfra/testinfra-%{version}.tar.gz
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module pywinrm}
++++++ testinfra-3.1.0.tar.gz -> testinfra-3.2.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/testinfra-3.1.0/CHANGELOG.rst
new/testinfra-3.2.0/CHANGELOG.rst
--- old/testinfra-3.1.0/CHANGELOG.rst 2019-08-18 13:34:56.000000000 +0200
+++ new/testinfra-3.2.0/CHANGELOG.rst 2019-09-08 14:15:25.000000000 +0200
@@ -2,6 +2,15 @@
Changelog
=========
+3.2.0
+=====
+
+* New module "environment" for getting remote environment variables
+* New module "block_device" exposing block device informations
+* Add a global flag --force-ansible to the command line
+* Raise an error in case of missing ansible inventory file
+* Fix an escape issue with ansible ssh args set inventory or configuration file
+
3.1.0
=====
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/testinfra-3.1.0/PKG-INFO new/testinfra-3.2.0/PKG-INFO
--- old/testinfra-3.1.0/PKG-INFO 2019-08-18 19:03:01.000000000 +0200
+++ new/testinfra-3.2.0/PKG-INFO 2019-09-08 14:16:28.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: testinfra
-Version: 3.1.0
+Version: 3.2.0
Summary: Test infrastructures
Home-page: https://github.com/philpep/testinfra
Author: Philippe Pepiot
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/testinfra-3.1.0/doc/source/backends.rst
new/testinfra-3.2.0/doc/source/backends.rst
--- old/testinfra-3.1.0/doc/source/backends.rst 2019-08-17 12:44:33.000000000
+0200
+++ new/testinfra-3.2.0/doc/source/backends.rst 2019-09-08 14:11:51.000000000
+0200
@@ -80,7 +80,7 @@
The ansible backend is able to parse ansible inventories to get host
connection details.
For local, ssh, paramiko or docker connections it will use the equivalent
-testinfra connection backend, unless `force_ansible=True`.
+testinfra connection backend, unless `force_ansible=True` (or
``--force-ansible``) is set.
For other connections types or when `force_ansible=True`, testinfra will run
all commands through ansible, which is substantially slower than using native
@@ -88,9 +88,10 @@
Examples::
- $ py.test --hosts=all # tests all inventory hosts
+ $ py.test --hosts='ansible://all' # tests all inventory hosts
$ py.test --hosts='ansible://host1,ansible://host2'
$ py.test --hosts='ansible://web*'
+ $ py.test --force-ansible --hosts='ansible://all'
$ py.test --hosts='ansible://host?force_ansible=True'
kubectl
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/testinfra-3.1.0/doc/source/modules.rst
new/testinfra-3.2.0/doc/source/modules.rst
--- old/testinfra-3.1.0/doc/source/modules.rst 2019-07-07 01:41:09.000000000
+0200
+++ new/testinfra-3.2.0/doc/source/modules.rst 2019-09-08 12:10:31.000000000
+0200
@@ -31,6 +31,10 @@
:class:`testinfra.modules.docker.Docker` class
+ .. attribute:: environment
+
+ :class:`testinfra.modules.environment.Environment` class
+
.. attribute:: file
:class:`testinfra.modules.file.File` class
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/testinfra-3.1.0/test/test_backends.py
new/testinfra-3.2.0/test/test_backends.py
--- old/testinfra-3.1.0/test/test_backends.py 2019-08-18 13:15:06.000000000
+0200
+++ new/testinfra-3.2.0/test/test_backends.py 2019-09-08 14:09:06.000000000
+0200
@@ -199,21 +199,21 @@
}
[email protected]('hostname,kwargs,inventory,expected', [
- ('host', {}, b'host ansible_connection=local ansible_become=yes
ansible_become_user=u', { # noqa
[email protected]('kwargs,inventory,expected', [
+ ({}, b'host ansible_connection=local ansible_become=yes
ansible_become_user=u', { # noqa
'NAME': 'local',
'sudo': True,
'sudo_user': 'u',
}),
- ('host', {}, b'host', {
+ ({}, b'host', {
'NAME': 'ssh',
'host.name': 'host',
}),
- ('host', {}, b'host ansible_connection=smart', {
+ ({}, b'host ansible_connection=smart', {
'NAME': 'ssh',
'host.name': 'host',
}),
- ('host', {}, b'host ansible_host=127.0.1.1 ansible_user=u
ansible_ssh_private_key_file=key ansible_port=2222 ansible_become=yes
ansible_become_user=u', { # noqa
+ ({}, b'host ansible_host=127.0.1.1 ansible_user=u
ansible_ssh_private_key_file=key ansible_port=2222 ansible_become=yes
ansible_become_user=u', { # noqa
'NAME': 'ssh',
'sudo': True,
'sudo_user': 'u',
@@ -221,7 +221,7 @@
'host.port': '2222',
'ssh_identity_file': 'key',
}),
- ('host', {}, b'host ansible_host=127.0.1.1 ansible_user=u
ansible_private_key_file=key ansible_port=2222 ansible_become=yes
ansible_become_user=u', { # noqa
+ ({}, b'host ansible_host=127.0.1.1 ansible_user=u
ansible_private_key_file=key ansible_port=2222 ansible_become=yes
ansible_become_user=u', { # noqa
'NAME': 'ssh',
'sudo': True,
'sudo_user': 'u',
@@ -229,34 +229,34 @@
'host.port': '2222',
'ssh_identity_file': 'key',
}),
- ('host', {}, b'host ansible_ssh_common_args="-o LogLevel=FATAL"', {
+ ({}, b'host ansible_ssh_common_args="-o LogLevel=FATAL"', {
'NAME': 'ssh',
'host.name': 'host',
'ssh_extra_args': '-o LogLevel=FATAL',
}),
- ('host', {}, b'host ansible_ssh_extra_args="-o LogLevel=FATAL"', {
+ ({}, b'host ansible_ssh_extra_args="-o LogLevel=FATAL"', {
'NAME': 'ssh',
'host.name': 'host',
'ssh_extra_args': '-o LogLevel=FATAL',
}),
- ('host', {}, b'host ansible_ssh_common_args="-o StrictHostKeyChecking=no"
ansible_ssh_extra_args="-o LogLevel=FATAL"', { # noqa
+ ({}, b'host ansible_ssh_common_args="-o StrictHostKeyChecking=no"
ansible_ssh_extra_args="-o LogLevel=FATAL"', { # noqa
'NAME': 'ssh',
'host.name': 'host',
'ssh_extra_args': '-o StrictHostKeyChecking=no -o LogLevel=FATAL',
}),
- ('host', {}, b'host ansible_connection=docker', {
+ ({}, b'host ansible_connection=docker', {
'NAME': 'docker',
'name': 'host',
'user': None,
}),
- ('host', {}, b'host ansible_connection=docker ansible_become=yes
ansible_become_user=u ansible_user=z ansible_host=container', { # noqa
+ ({}, b'host ansible_connection=docker ansible_become=yes
ansible_become_user=u ansible_user=z ansible_host=container', { # noqa
'NAME': 'docker',
'name': 'container',
'user': 'z',
'sudo': True,
'sudo_user': 'u',
}),
- ('host', {'ssh_config': '/ssh_config', 'ssh_identity_file': '/id_ed25519'},
+ ({'ssh_config': '/ssh_config', 'ssh_identity_file': '/id_ed25519'},
b'host', {
'NAME': 'ssh',
'host.name': 'host',
@@ -264,15 +264,39 @@
'ssh_identity_file': '/id_ed25519',
}),
])
-def test_ansible_get_host(hostname, kwargs, inventory, expected):
+def test_ansible_get_host(kwargs, inventory, expected):
with tempfile.NamedTemporaryFile() as f:
f.write(inventory + b'\n')
f.flush()
- backend = AnsibleRunner(f.name).get_host(hostname, **kwargs).backend
+ backend = AnsibleRunner(f.name).get_host('host', **kwargs).backend
for attr, value in expected.items():
assert operator.attrgetter(attr)(backend) == value
[email protected]('inventory,expected', [
+ (b'host', (
+ 'ssh -o ConnectTimeout=10 -o ControlMaster=auto '
+ '-o ControlPersist=60s host true')),
+ # avoid interference between our ssh backend and ansible_ssh_extra_args
+ (b'host ansible_ssh_extra_args="-o ConnectTimeout=5 -o ControlMaster=auto '
+ b'-o ControlPersist=10s"', (
+ 'ssh -o ConnectTimeout=5 -o ControlMaster=auto -o '
+ 'ControlPersist=10s host true')),
+ # escape %
+ (b'host ansible_ssh_extra_args="-o ControlPath
~/.ssh/ansible/cp/%r@%h-%p"', ( # noqa
+ 'ssh -o ControlPath ~/.ssh/ansible/cp/%r@%h-%p -o ConnectTimeout=10 '
+ '-o ControlMaster=auto -o ControlPersist=60s host true')),
+])
+def test_ansible_ssh_command(inventory, expected):
+ with tempfile.NamedTemporaryFile() as f:
+ f.write(inventory + b'\n')
+ f.flush()
+ backend = AnsibleRunner(f.name).get_host('host').backend
+ cmd, cmd_args = backend._build_ssh_command('true')
+ command = backend.quote(' '.join(cmd), *cmd_args)
+ assert command == expected
+
+
def test_ansible_no_host():
with tempfile.NamedTemporaryFile() as f:
f.write(b'host\n')
@@ -284,8 +308,15 @@
with tempfile.NamedTemporaryFile() as f:
# empty or no inventory should not return any hosts except for
# localhost
- assert AnsibleRunner(f.name).get_hosts() == []
- assert AnsibleRunner(f.name).get_hosts('local*') == []
+ nohost = (
+ 'No inventory was parsed (missing file ?), '
+ 'only implicit localhost is available')
+ with pytest.raises(RuntimeError) as exc:
+ assert AnsibleRunner(f.name).get_hosts() == []
+ assert str(exc.value) == nohost
+ with pytest.raises(RuntimeError) as exc:
+ assert AnsibleRunner(f.name).get_hosts('local*') == []
+ assert str(exc.value) == nohost
assert AnsibleRunner(f.name).get_hosts('localhost') == ['localhost']
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/testinfra-3.1.0/test/test_modules.py
new/testinfra-3.2.0/test/test_modules.py
--- old/testinfra-3.1.0/test/test_modules.py 2019-08-17 12:44:33.000000000
+0200
+++ new/testinfra-3.2.0/test/test_modules.py 2019-09-08 12:10:31.000000000
+0200
@@ -124,6 +124,8 @@
break
time.sleep(1)
else:
+ if docker_image == "archlinux":
+ raise pytest.skip('FIXME: flapping test')
raise AssertionError('ssh is not running')
if docker_image == "ubuntu_xenial":
@@ -485,6 +487,10 @@
assert int(outdated['latest'].split('.')[0]) > 2
+def test_environment_home(host):
+ assert host.environment().get('HOME') == '/root'
+
+
def test_iptables(host):
ssh_rule_str = \
'-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/testinfra-3.1.0/testinfra/backend/ssh.py
new/testinfra-3.2.0/testinfra/backend/ssh.py
--- old/testinfra-3.1.0/testinfra/backend/ssh.py 2019-08-18
13:15:06.000000000 +0200
+++ new/testinfra-3.2.0/testinfra/backend/ssh.py 2019-09-08
14:09:06.000000000 +0200
@@ -40,7 +40,7 @@
cmd = ["ssh"]
cmd_args = []
if self.ssh_extra_args:
- cmd += [self.ssh_extra_args]
+ cmd.append(self.ssh_extra_args.replace('%', '%%'))
if self.ssh_config:
cmd.append("-F %s")
cmd_args.append(self.ssh_config)
@@ -53,8 +53,11 @@
if self.ssh_identity_file:
cmd.append("-i %s")
cmd_args.append(self.ssh_identity_file)
- cmd.append("-o ConnectTimeout={}".format(self.timeout))
- if self.controlpersist:
+ if 'connecttimeout' not in (self.ssh_extra_args or '').lower():
+ cmd.append("-o ConnectTimeout={}".format(self.timeout))
+ if self.controlpersist and (
+ 'controlmaster' not in (self.ssh_extra_args or '').lower()
+ ):
cmd.append("-o ControlMaster=auto -o ControlPersist=%ds" % (
self.controlpersist))
cmd.append("%s %s")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/testinfra-3.1.0/testinfra/modules/__init__.py
new/testinfra-3.2.0/testinfra/modules/__init__.py
--- old/testinfra-3.1.0/testinfra/modules/__init__.py 2019-07-07
01:41:09.000000000 +0200
+++ new/testinfra-3.2.0/testinfra/modules/__init__.py 2019-09-08
12:10:31.000000000 +0200
@@ -20,6 +20,7 @@
'ansible': 'ansible:Ansible',
'command': 'command:Command',
'docker': 'docker:Docker',
+ 'environment': 'environment:Environment',
'file': 'file:File',
'group': 'group:Group',
'interface': 'interface:Interface',
@@ -38,6 +39,7 @@
'sysctl': 'sysctl:Sysctl',
'system_info': 'systeminfo:SystemInfo',
'user': 'user:User',
+ 'block_device': 'blockdevice:BlockDevice',
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/testinfra-3.1.0/testinfra/modules/blockdevice.py
new/testinfra-3.2.0/testinfra/modules/blockdevice.py
--- old/testinfra-3.1.0/testinfra/modules/blockdevice.py 1970-01-01
01:00:00.000000000 +0100
+++ new/testinfra-3.2.0/testinfra/modules/blockdevice.py 2019-09-08
12:10:31.000000000 +0200
@@ -0,0 +1,150 @@
+# coding: utf-8
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from __future__ import unicode_literals
+
+from testinfra.modules.base import Module
+from testinfra.utils import cached_property
+
+
+class BlockDevice(Module):
+ """Information for block device.
+
+ Should be used with sudo or under root.
+
+ If device is not a block device, RuntimeError is raised.
+ """
+
+ def _data(self):
+ raise NotImplementedError
+
+ def __init__(self, device):
+ self.device = device
+ super(BlockDevice, self).__init__()
+
+ @property
+ def is_partition(self):
+ """Return True if the device is a partition.
+
+ >>> host.block_device("/dev/sda1").is_partition
+ True
+
+ >>> host.block_device("/dev/sda").is_partition
+ False
+
+
+ """
+ return self._data['start_sector'] > 0
+
+ @property
+ def size(self):
+ """Return size if the device in bytes.
+
+ >>> host.block_device("/dev/sda1").size
+ 512110190592
+
+ """
+ return self._data['size']
+
+ @property
+ def sector_size(self):
+ """Return sector size for the device in bytes.
+
+ >>> host.block_device("/dev/sda1").sector_size
+ 512
+ """
+ return self._data['sector_size']
+
+ @property
+ def block_size(self):
+ """Return block size for the device in bytes.
+
+ >>> host.block_device("/dev/sda").block_size
+ 4096
+ """
+ return self._data['block_size']
+
+ @property
+ def start_sector(self):
+ """Return start sector of the device on the underlaying device.
+
+ Usually the value is zero for full devices and is non-zero
+ for partitions.
+
+ >>> host.block_device("/dev/sda1").start_sector
+ 2048
+
+ >>> host.block_device("/dev/md0").start_sector
+ 0
+ """
+ return self._data['sector_size']
+
+ @property
+ def is_writable(self):
+ """Return True if device is writable (have no RO status)
+
+ >>> host.block_device("/dev/sda").is_writable
+ True
+
+ >>> host.block_device("/dev/loop1").is_writable
+ False
+ """
+ mode = self._data['rw_mode']
+ if mode == 'rw':
+ return True
+ if mode == 'ro':
+ return False
+ raise ValueError('Unexpected value for rw: %s' % mode)
+
+ @property
+ def ra(self):
+ """Return Read Ahead for the device in 512-bytes sectors.
+
+ >>> host.block_device("/dev/sda").ra
+ 256
+ """
+ return self._data['read_ahead']
+
+ @classmethod
+ def get_module_class(cls, host):
+ if host.system_info.type == 'linux':
+ return LinuxBlockDevice
+ raise NotImplementedError
+
+ def __repr__(self):
+ return '<BlockDevice(path=%s)>' % self.device
+
+
+class LinuxBlockDevice(BlockDevice):
+
+ @cached_property
+ def _data(self):
+ header = ['RO', 'RA', 'SSZ', 'BSZ', 'StartSec', 'Size', 'Device']
+ command = 'blockdev --report %s'
+ blockdev = self.run(command % self.device)
+ if blockdev.rc != 0 or blockdev.stderr:
+ raise RuntimeError("Failed to gather data: %s" % blockdev.stderr)
+ output = blockdev.stdout.splitlines()
+ if len(output) < 2:
+ raise RuntimeError("No data from %s" % self.device)
+ if output[0].split() != header:
+ raise RuntimeError('Unknown output of blockdev: %s' % output[0])
+ fields = output[1].split()
+ return {
+ 'rw_mode': str(fields[0]),
+ 'read_ahead': int(fields[1]),
+ 'sector_size': int(fields[2]),
+ 'block_size': int(fields[3]),
+ 'start_sector': int(fields[4]),
+ 'size': int(fields[5])
+ }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/testinfra-3.1.0/testinfra/modules/environment.py
new/testinfra-3.2.0/testinfra/modules/environment.py
--- old/testinfra-3.1.0/testinfra/modules/environment.py 1970-01-01
01:00:00.000000000 +0100
+++ new/testinfra-3.2.0/testinfra/modules/environment.py 2019-09-08
12:10:46.000000000 +0200
@@ -0,0 +1,40 @@
+# coding: utf-8
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from __future__ import unicode_literals
+
+from testinfra.modules.base import InstanceModule
+
+
+class Environment(InstanceModule):
+ """Get Environment variables
+
+ Example:
+
+ >>> host.environment()
+ {
+ "EDITOR": "vim",
+ "SHELL": "/bin/bash",
+ [...]
+ }
+ """
+
+ def __call__(self):
+ ret_val = dict(
+ i.split('=', 1) for i in self.check_output('env -0').split(
+ '\x00') if i
+ )
+ return ret_val
+
+ def __repr__(self):
+ return "<environment>"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/testinfra-3.1.0/testinfra/plugin.py
new/testinfra-3.2.0/testinfra/plugin.py
--- old/testinfra-3.1.0/testinfra/plugin.py 2019-08-04 13:46:26.000000000
+0200
+++ new/testinfra-3.2.0/testinfra/plugin.py 2019-09-08 14:09:06.000000000
+0200
@@ -88,6 +88,14 @@
help="Ansible inventory file",
)
group.addoption(
+ "--force-ansible",
+ action="store_true",
+ dest="force_ansible",
+ help=(
+ 'Force use of ansible connection backend only (slower but all '
+ 'ansible connection options are handled)')
+ )
+ group.addoption(
"--nagios",
action="store_true",
dest="nagios",
@@ -111,6 +119,7 @@
sudo=metafunc.config.option.sudo,
sudo_user=metafunc.config.option.sudo_user,
ansible_inventory=metafunc.config.option.ansible_inventory,
+ force_ansible=metafunc.config.option.force_ansible,
)
params = sorted(params, key=lambda x: x.backend.get_pytest_id())
ids = [e.backend.get_pytest_id() for e in params]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/testinfra-3.1.0/testinfra/utils/ansible_runner.py
new/testinfra-3.2.0/testinfra/utils/ansible_runner.py
--- old/testinfra-3.1.0/testinfra/utils/ansible_runner.py 2019-08-18
13:15:06.000000000 +0200
+++ new/testinfra-3.2.0/testinfra/utils/ansible_runner.py 2019-09-08
13:42:59.000000000 +0200
@@ -63,7 +63,9 @@
def get_ansible_host(config, inventory, host, ssh_config=None,
ssh_identity_file=None):
if is_empty_inventory(inventory):
- return testinfra.get_host('local://')
+ if host == 'localhost':
+ return testinfra.get_host('local://')
+ return None
hostvars = inventory['_meta'].get('hostvars', {}).get(host, {})
connection = hostvars.get('ansible_connection', 'ssh')
if connection not in (
@@ -139,6 +141,10 @@
# empty inventory should not return any hosts except for localhost
if pattern == 'localhost':
result.add('localhost')
+ else:
+ raise RuntimeError(
+ 'No inventory was parsed (missing file ?), '
+ 'only implicit localhost is available')
else:
for group in inventory:
groupmatch = fnmatch.fnmatch(group, pattern)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/testinfra-3.1.0/testinfra.egg-info/PKG-INFO
new/testinfra-3.2.0/testinfra.egg-info/PKG-INFO
--- old/testinfra-3.1.0/testinfra.egg-info/PKG-INFO 2019-08-18
19:03:00.000000000 +0200
+++ new/testinfra-3.2.0/testinfra.egg-info/PKG-INFO 2019-09-08
14:16:28.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: testinfra
-Version: 3.1.0
+Version: 3.2.0
Summary: Test infrastructures
Home-page: https://github.com/philpep/testinfra
Author: Philippe Pepiot
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/testinfra-3.1.0/testinfra.egg-info/SOURCES.txt
new/testinfra-3.2.0/testinfra.egg-info/SOURCES.txt
--- old/testinfra-3.1.0/testinfra.egg-info/SOURCES.txt 2019-08-18
19:03:00.000000000 +0200
+++ new/testinfra-3.2.0/testinfra.egg-info/SOURCES.txt 2019-09-08
14:16:28.000000000 +0200
@@ -61,8 +61,10 @@
testinfra/modules/addr.py
testinfra/modules/ansible.py
testinfra/modules/base.py
+testinfra/modules/blockdevice.py
testinfra/modules/command.py
testinfra/modules/docker.py
+testinfra/modules/environment.py
testinfra/modules/file.py
testinfra/modules/group.py
testinfra/modules/interface.py