Skip to content

Testinfra fails if the "~/.ansible/cp" path doesn't exist #735

@koef

Description

@koef

Hello,

After updating to release v9.0.0, we've noticed a regression. When the "~/.ansible/cp" path is missing, tests seem to fail with the following error:

self = <testinfra.backend.ssh.SshBackend object at 0x10199f3d0>
command = 'uname -s'

    def run_ssh(self, command: str) -> base.CommandResult:
        cmd, cmd_args = self._build_ssh_command(command)
        out = self.run_local(" ".join(cmd), *cmd_args)
        out.command = self.encode(command)
        if out.rc == 255:
            # ssh exits with the exit status of the remote command or with 255
            # if an error occurred.
>           raise RuntimeError(out)
E           RuntimeError: CommandResult(command=b'uname -s', exit_status=255, stdout=None, stderr=b"Warning: Permanently added '192.168.1.87' (ED25519) to the list of known hosts.\r\nunix_listener: cannot bind to path /Users/user/.ansible/cp/192.168.1.87-22-some-user.8yRLDJr64HeCjBh0: No such file or directory\r\n")

cmd        = ['ssh',
 '-F %s',
 '-o User=%s',
 '-o Port=%s',
 '-o ConnectTimeout=10',
 '-o ControlMaster=auto -o ControlPersist=60s',
 '-o ControlPath=~/.ansible/cp/%%h-%%p-%%r',
 '%s %s']
cmd_args   = ['../../../_molecule_resources/default/ssh_config',
 'some-user',
 '22',
 '192.168.1.87',
 'uname -s']
command    = 'uname -s'
out        = CommandResult(command=b'uname -s', exit_status=255, stdout=None, stderr=b"Warning: Permanently added '192.168.1.87' (ED25519) to the list of known hosts.\r\nunix_listener: cannot bind to path /Users/user/.ansible/cp/192.168.1.87-22-some-user.8yRLDJr64HeCjBh0: No such file or directory\r\n")
self       = <testinfra.backend.ssh.SshBackend object at 0x10199f3d0>

I believe the root cause might be associated with PR #713.

It might be beneficial for Testinfra to verify if the "directory" exists prior to it's utilization.

Thank you for looking into this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions