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

push_args destination now requires full path with image name and tag when default transport is used #830

Open
jakestec opened this issue Aug 28, 2024 · 4 comments
Labels
wontfix This will not be worked on

Comments

@jakestec
Copy link
Contributor

Hello,

I've been using the latest collection version (v1.15.4) with an existing playbook to build container images. When I went to push a new image today I got the following error related to the line of code below:

Destination must be a full URL or path to a directory.

if "/" not in dest_string and "@" not in dest_string and "docker-daemon" not in dest_string:

My task:

container_registry: "my.registry.domain.name"
...
    - name: Create and push EE => "{{ ee_name }}:{{ ee_tag }}"
      containers.podman.podman_image:
        name: "{{ ee_name }}"
        tag: "{{ ee_tag }}"
        path: "{{ ansible_env.PWD }}/build"
        push: true
        auth_file: "{{ lookup('ansible.builtin.env', 'XDG_RUNTIME_DIR') }}/containers/auth.json"
        validate_certs: true
        push_args:
          dest: "{{ container_registry }}"

Debugging I can see its not forming the push arguments correctly:

    "podman_actions": [
        "/usr/bin/podman image ls rcnet-ee:1.9 --format json",
        "/usr/bin/podman inspect rcnet-ee:1.9 --format json",
        "/usr/bin/podman push --tls-verify --authfile /run/user/1001/containers/auth.json my-ee:1.9 my.registry.domain.name",

We should see:

 "/usr/bin/podman push --tls-verify --authfile /run/user/1001/containers/auth.json my-ee:1.9 my.registry.domain.name/my-ee:1.9",

The above task is working in v1.12.1. I was able to fix the issue by modifying the destination in the task to include the image name and tag like so:

    - name: Create and push EE => "{{ ee_name }}:{{ ee_tag }}"
      containers.podman.podman_image:
        name: "{{ ee_name }}"
        tag: "{{ ee_tag }}"
        path: "{{ ansible_env.PWD }}/build"
        push: true
        auth_file: "{{ lookup('ansible.builtin.env', 'XDG_RUNTIME_DIR') }}/containers/auth.json"
        validate_certs: true
        push_args:
          dest: "{{ container_registry }}/{{ ee_name }}:{{ ee_tag }}"

I am not sure if this is intended, or an unplanned side effect of the changes implemented by 4985d48 when doing some further checking on the transport type.

@sshnaidm
Copy link
Member

It would help more if instead of putting variables names "{{ ee_name }}" you put real values, hard to guess what you pass to the task.
If you pass dest as my.registry.domain.name only, it won't work, you need to set a name as well. The issue is that it worked before while it shouldn't have. The Podman itself fails if you pass the registry only in command line. We stick to Podman behavior now.
It's kind of side-effect of fixing other issues with transports and adding another features for pushing, we don't have a way to understand either it's a different image, registry, archive or anything else in dest, neither Podman does. That's why it's required now to put exactly what you need in dest (exactly as in Podman command line).

@sshnaidm sshnaidm added the wontfix This will not be worked on label Aug 29, 2024
@jakestec
Copy link
Contributor Author

jakestec commented Sep 18, 2024

Hey @sshnaidm, thanks for the response and sorry for the delay I was away from my desk for a couple weeks.

The explanation makes sense, however maybe we should update the documentation to reflect that. Because from the current functionality this example from the docs wont work since the dest is just a registry and no name or tag is provided.

https://docs.ansible.com/ansible/latest/collections/containers/podman/podman_image_module.html#examples

- name: Build and push an image using an auth file
  containers.podman.podman_image:
    name: nginx
    push: true
    auth_file: /etc/containers/auth.json
    push_args:
      dest: quay.io/acme

It should show:

- name: Build and push an image using an auth file
  containers.podman.podman_image:
    name: nginx
    push: true
    auth_file: /etc/containers/auth.json
    push_args:
      dest: quay.io/acme/nginx:tag

I am a little conflicted on the current functionality because the task builds and pushes the image as one action. So in theory its fair to assume you want to build nginx and push nginx to the dest provided in the task. Having to again specify the image name in dest is not obvious. If its not specified maybe it should just take what's in the name field, or at least explain in the error what its looking for.

Example error:

Destination must be a full URL or path to a directory with image name and tag.

@sshnaidm
Copy link
Member

@jakestec Yeah, let's fix the docs and error message, would you like to propose a patch?

Having to again specify the image name in dest is not obvious

Yes, it's not obvious if you have been doing this with previous versions of podman_image, but that won't work in Podman as well. So it's better to keep the consistency here.

@jakestec
Copy link
Contributor Author

Sure thing, I've submitted my PR here: #848

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants