Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Podman get_containers() fails against the ansible backend #694

Open
BenjaminSchubert opened this issue Apr 23, 2023 · 0 comments
Open

Podman get_containers() fails against the ansible backend #694

BenjaminSchubert opened this issue Apr 23, 2023 · 0 comments

Comments

@BenjaminSchubert
Copy link

When running host.podman.get_containers(), podman generates the following command that is run:

podman ps --all --format {{.Names}}

The Ansible providers interprets the {{ as the start of a jinja2 template, and thus tries to interpet it, which fails with:

self = <testinfra.backend.ansible.AnsibleBackend object at 0x7f4af339e7d0>
command = "podman ps --all --format '{{.Names}}'", args = (), kwargs = {}
host = None
out = {'msg': "template error while templating string: unexpected '.'. String: podman ps --all --format '{{.Names}}'. unexpected '.'"}

    def run(self, command, *args, **kwargs):
        command = self.get_command(command, *args)
        if not self.force_ansible:
            host = self.ansible_runner.get_host(
                self.host,
                ssh_config=self.ssh_config,
                ssh_identity_file=self.ssh_identity_file,
            )
            if host is not None:
                return host.run(command)
        out = self.run_ansible("shell", module_args=command, check=False)
        return self.result(
>           out["rc"],
            command,
            stdout_bytes=None,
            stderr_bytes=None,
            stdout=out["stdout"],
            stderr=out["stderr"],
        )
E       KeyError: 'rc'

In the meantime, host.run("podman ps --all --format '{{ '{{' }}.Names{{ '}}' }}'") works, but is a bit more manual.

I would be happy to provide a fix, but I am unsure how best to do this, given that in other cases, interpolation is what is wanted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant