pytest-testinfra
pytest-testinfra copied to clipboard
Ansible runner error while creating temporary directory in podman containers
Environment deials:
- Python 3.9.0rc2 (On Fedora 33)
- testinfra 5.3.1
- molecule 3.1.4
- molecule-podman 0.2.3
- ansible 2.10.1
[gw4] linux -- Python 3.9.0 /home/kdas/code/securedrop/.venv/bin/python3
host = <testinfra.host.Host ansible://xenial-sd-keyring>
build_path = '/tmp/build-'
@pytest.mark.parametrize('build_path', [
'/tmp/build-',
'/tmp/rsync-filter',
'/tmp/src_install_files',
'/tmp/build-securedrop-keyring',
'/tmp/build-securedrop-ossec-agent',
'/tmp/build-securedrop-ossec-server',
])
def test_build_ossec_apt_dependencies(host, build_path):
"""
Ensure that unwanted build paths are absent. Most of these were created
as unwanted side-effects during CI-related changes to the build scripts.
All paths are rightly considered "legacy" and should never be present on
the build host. This test is strictly for guarding against regressions.
"""
> assert not host.file(build_path).exists
tests/test_legacy_paths.py:20:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../.venv/lib64/python3.9/site-packages/testinfra/host.py:111: in __getattr__
obj = module_class.get_module(self)
../../.venv/lib64/python3.9/site-packages/testinfra/modules/base.py:19: in get_module
klass = cls.get_module_class(_host)
../../.venv/lib64/python3.9/site-packages/testinfra/modules/file.py:191: in get_module_class
if host.system_info.type == "linux":
../../.venv/lib64/python3.9/site-packages/testinfra/modules/systeminfo.py:144: in type
return self.sysinfo["type"]
../../.venv/lib64/python3.9/site-packages/testinfra/utils/__init__.py:29: in __get__
value = obj.__dict__[self.func.__name__] = self.func(obj)
../../.venv/lib64/python3.9/site-packages/testinfra/modules/systeminfo.py:38: in sysinfo
sysinfo.update(**self._get_linux_sysinfo())
../../.venv/lib64/python3.9/site-packages/testinfra/modules/systeminfo.py:54: in _get_linux_sysinfo
lsb = self.run("lsb_release -a")
../../.venv/lib64/python3.9/site-packages/testinfra/host.py:75: in run
return self.backend.run(command, *args, **kwargs)
../../.venv/lib64/python3.9/site-packages/testinfra/backend/ansible.py:48: in run
out = self.run_ansible('shell', module_args=command, check=False)
../../.venv/lib64/python3.9/site-packages/testinfra/backend/ansible.py:54: in run_ansible
result = self.ansible_runner.run_module(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <testinfra.utils.ansible_runner.AnsibleRunner object at 0x7fc31af631c0>
host = 'xenial-sd-keyring', module_name = 'shell'
module_args = 'lsb_release -a', options = {'check': False}
cmd = 'ansible --tree %s -i %s -m %s --args %s %s'
args = ['/tmp/tmp3e5j6rx2', '/home/kdas/.cache/molecule/securedrop/builder-xenial/inventory/ansible_inventory.yml', 'shell', 'lsb_release -a', 'xenial-sd-keyring']
options_cli = '', options_args = [], d = '/tmp/tmp3e5j6rx2'
def run_module(self, host, module_name, module_args, **options):
cmd, args = 'ansible --tree %s', [None]
if self.inventory_file:
cmd += ' -i %s'
args += [self.inventory_file]
cmd += ' -m %s'
args += [module_name]
if module_args:
cmd += ' --args %s'
args += [module_args]
options_cli, options_args = self.options_to_cli(options)
if options_cli:
cmd += ' ' + options_cli
args.extend(options_args)
cmd += ' %s'
args += [host]
with tempfile.TemporaryDirectory() as d:
args[0] = d
> out = local.run_expect([0, 2, 8], cmd, *args)
E AssertionError: Unexpected exit code 4 for CommandResult(command=b"ansible --tree /tmp/tmp3e5j6rx2 -i /home/kdas/.cache/molecule/securedrop/builder-xenial/inventory/ansible_inventory.yml -m shell --args 'lsb_release -a' xenial-sd-keyring", exit_status=4, stdout=b'xenial-sd-keyring | UNREACHABLE! => {\n "changed": false,\n "msg": "Failed to create temporary directory.In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in \\"/tmp\\", for more error information use -vvv. Failed command was: ( umask 77 && mkdir -p \\"` echo ~/.ansible/tmp `\\"&& mkdir \\"` echo ~/.ansible/tmp/ansible-tmp-1603432275.0584002-311977-140599228456800 `\\" && echo ansible-tmp-1603432275.0584002-311977-140599228456800=\\"` echo ~/.ansible/tmp/ansible-tmp-1603432275.0584002-311977-140599228456800 `\\" ), exited with result 255",\n "unreachable": true\n}\n', stderr=None)
E assert 4 in [0, 2, 8]
E + where 4 = CommandResult(command=b"ansible --tree /tmp/tmp3e5j6rx2 -i /home/kdas/.cache/molecule/securedrop/builder-xenial/invent...1603432275.0584002-311977-140599228456800 `\\" ), exited with result 255",\n "unreachable": true\n}\n', stderr=None).rc
../../.venv/lib64/python3.9/site-packages/testinfra/utils/ansible_runner.py:286: AssertionError