From bbf0a7fe5fe01c1399aad84a6d323d04e807b4e9 Mon Sep 17 00:00:00 2001 From: Sagi Shnaidman Date: Tue, 19 May 2026 23:26:37 +0300 Subject: [PATCH] Add support for aliases for Quadlets Signed-off-by: Sagi Shnaidman --- plugins/module_utils/podman/quadlet.py | 7 +- .../targets/podman_image/tasks/main.yml | 66 +++++++++++++++++++ 2 files changed, 71 insertions(+), 2 deletions(-) diff --git a/plugins/module_utils/podman/quadlet.py b/plugins/module_utils/podman/quadlet.py index cb27d64..c27609e 100644 --- a/plugins/module_utils/podman/quadlet.py +++ b/plugins/module_utils/podman/quadlet.py @@ -75,17 +75,19 @@ class Quadlet: Convert parameter values as per param_map. """ processed_params = [] + seen_quadlet_keys = set() for param_key, quadlet_key in self.param_map.items(): + if quadlet_key in seen_quadlet_keys: + continue value = self.custom_params.get(param_key) if value is not None: + seen_quadlet_keys.add(quadlet_key) if isinstance(value, list): - # Add an entry for each item in the list for item in value: processed_params.append([quadlet_key, item]) else: if isinstance(value, bool): value = str(value).lower() - # Add a single entry for the key processed_params.append([quadlet_key, value]) return processed_params @@ -716,6 +718,7 @@ class ImageQuadlet(Quadlet): "AllTags": "AllTags", "arch": "Arch", "authfile": "AuthFile", + "auth_file": "AuthFile", "ca_cert_dir": "CertDir", "creds": "Creds", "DecryptionKey": "DecryptionKey", diff --git a/tests/integration/targets/podman_image/tasks/main.yml b/tests/integration/targets/podman_image/tasks/main.yml index 90e9584..c3d2e9f 100644 --- a/tests/integration/targets/podman_image/tasks/main.yml +++ b/tests/integration/targets/podman_image/tasks/main.yml @@ -606,6 +606,72 @@ - quad3 is changed - "'arm64' in quad3.diff.after" + - name: Create quadlet image file with auth_file + containers.podman.podman_image: + executable: "{{ test_executable | default('podman') }}" + name: quay.io/coreos/coreos-installer:latest + state: quadlet + auth_file: /path/to/auth.json + quadlet_dir: /tmp/ + quadlet_filename: authfile_test + register: quad_authfile + + - name: Check AuthFile line appears exactly once + shell: grep -c 'AuthFile=' /tmp/authfile_test.image + register: authfile_count + + - name: Fail if AuthFile appears more than once + assert: + that: + - authfile_count.stdout | int == 1 + fail_msg: "AuthFile should appear exactly once, found {{ authfile_count.stdout }} times" + + - name: Check AuthFile value is correct + lineinfile: + path: /tmp/authfile_test.image + line: "AuthFile=/path/to/auth.json" + state: present + check_mode: yes + register: authfile_line_check + + - name: Fail if AuthFile line is not present + assert: + that: + - authfile_line_check is not changed + + - name: Create quadlet image file with authfile alias + containers.podman.podman_image: + executable: "{{ test_executable | default('podman') }}" + name: quay.io/coreos/coreos-installer:latest + state: quadlet + authfile: /path/to/auth2.json + quadlet_dir: /tmp/ + quadlet_filename: authfile_alias_test + register: quad_authfile_alias + + - name: Check AuthFile line appears exactly once with alias + shell: grep -c 'AuthFile=' /tmp/authfile_alias_test.image + register: authfile_alias_count + + - name: Fail if AuthFile appears more than once with alias + assert: + that: + - authfile_alias_count.stdout | int == 1 + fail_msg: "AuthFile should appear exactly once, found {{ authfile_alias_count.stdout }} times" + + - name: Check AuthFile value is correct with alias + lineinfile: + path: /tmp/authfile_alias_test.image + line: "AuthFile=/path/to/auth2.json" + state: present + check_mode: yes + register: authfile_alias_line_check + + - name: Fail if AuthFile line is not present with alias + assert: + that: + - authfile_alias_line_check is not changed + - include_tasks: additional_tests.yml - include_tasks: test_issue_947.yml