|
147 | 147 | pull=dict(type="str", choices=["always", "missing", "never", "newer"]), |
148 | 148 | quadlet_dir=dict(type="path"), |
149 | 149 | quadlet_filename=dict(type="str"), |
| 150 | + quadlet_file_mode=dict(type="raw"), |
150 | 151 | quadlet_options=dict(type="list", elements="str"), |
151 | 152 | rdt_class=dict(type="str"), |
152 | 153 | read_only=dict(type="bool"), |
|
215 | 216 | "published_ports": "portmappings", |
216 | 217 | "ports": "portmappings", |
217 | 218 | "pids_mode": "pidns", |
| 219 | + "pid": "pidns", |
218 | 220 | "ipc_mode": "ipcns", |
219 | 221 | "ipc": "ipcns", |
220 | 222 | "uts": "utsns", |
@@ -400,43 +402,28 @@ def translate(self): |
400 | 402 | c_port, protocol = (parts[0].split("/") + ["tcp"])[:2] |
401 | 403 | total_ports.append( |
402 | 404 | { |
403 | | - "container_port": int(p) if "-" not in p else int(p.split("-")[0]), |
| 405 | + "container_port": int(p), |
404 | 406 | "protocol": protocol if "udp" not in p else "udp", |
405 | | - # "host_port": int(parts[0].split("/")[0]), |
406 | | - "range": 0 if "-" not in p else int(p.split("-")[1]) - int(p.split("-")[0]), |
| 407 | + # "host_port": int(parts[0].split("/")[0]) |
407 | 408 | } |
408 | 409 | ) |
409 | 410 | elif len(parts) == 2: |
410 | 411 | c_port, protocol = (parts[1].split("/") + ["tcp"])[:2] |
411 | | - cport = int(c_port) if "-" not in c_port else int(c_port.split("-")[0]) |
412 | | - hport = ( |
413 | | - int(parts[0].split("/")[0]) |
414 | | - if "-" not in parts[0] |
415 | | - else int(parts[0].split("/")[0].split("-")[0]) |
416 | | - ) |
417 | 412 | total_ports.append( |
418 | 413 | { |
419 | | - "container_port": cport, |
420 | | - "host_port": hport, |
| 414 | + "container_port": int(c_port), |
| 415 | + "host_port": int(parts[0].split("/")[0]), |
421 | 416 | "protocol": protocol if "udp" not in p else "udp", |
422 | | - "range": 0 if "-" not in c_port else int(c_port.split("-")[1]) - int(c_port.split("-")[0]), |
423 | 417 | } |
424 | 418 | ) |
425 | 419 | elif len(parts) == 3: |
426 | 420 | c_port, protocol = (parts[1].split("/") + ["tcp"])[:2] |
427 | | - hport = int(c_port) if "-" not in c_port else int(c_port.split("-")[0]) |
428 | | - cport = ( |
429 | | - int(parts[2].split("/")[0]) |
430 | | - if "-" not in parts[2] |
431 | | - else int(parts[2].split("/")[0].split("-")[0]) |
432 | | - ) |
433 | 421 | total_ports.append( |
434 | 422 | { |
435 | | - "host_port": hport, |
436 | | - "container_port": cport, |
| 423 | + "host_port": int(c_port), |
| 424 | + "container_port": int(parts[2].split("/")[0]), |
437 | 425 | "protocol": protocol if "udp" not in p else "udp", |
438 | 426 | "host_ip": parts[0], |
439 | | - "range": 0 if "-" not in c_port else int(c_port.split("-")[1]) - int(c_port.split("-")[0]), |
440 | 427 | } |
441 | 428 | ) |
442 | 429 | transformed["portmappings"] = total_ports |
@@ -1242,6 +1229,9 @@ def _diff_generic(self, module_arg, cmd_arg, boolean_type=False): |
1242 | 1229 | cmd = self._get_create_command_annotation() |
1243 | 1230 | if cmd: |
1244 | 1231 | params = self.clean_aliases(self.params) |
| 1232 | + self.module.log( |
| 1233 | + "PODMAN-DEBUG: cmd_arg = %s and param arg = %s" % (cmd.get(module_arg), params.get(module_arg)) |
| 1234 | + ) |
1245 | 1235 | return self._diff_update_and_compare(module_arg, cmd.get(module_arg), params.get(module_arg)) |
1246 | 1236 | return self._diff_update_and_compare(module_arg, None, None) |
1247 | 1237 |
|
@@ -1862,11 +1852,25 @@ def ensure_image_exists(module, image, module_params, client): |
1862 | 1852 | image_pull_cmd = [module_exec, "image", "pull", image] |
1863 | 1853 | if module_params["tls_verify"] is False: |
1864 | 1854 | image_pull_cmd.append("--tls-verify=false") |
| 1855 | + if module_params["authfile"]: |
| 1856 | + image_pull_cmd.extend(["--authfile", module_params["authfile"]]) |
| 1857 | + if module_params["arch"]: |
| 1858 | + image_pull_cmd.append("--arch=%s" % module_params["arch"]) |
| 1859 | + if module_params["decryption_key"]: |
| 1860 | + image_pull_cmd.append("--decryption-key=%s" % module_params["decryption_key"]) |
| 1861 | + if module_params["platform"]: |
| 1862 | + image_pull_cmd.append("--platform=%s" % module_params["platform"]) |
| 1863 | + if module_params["os"]: |
| 1864 | + image_pull_cmd.append("--os=%s" % module_params["os"]) |
| 1865 | + if module_params["variant"]: |
| 1866 | + image_pull_cmd.append("--variant=%s" % module_params["variant"]) |
| 1867 | + if module_params.get("debug"): |
| 1868 | + module.log("PODMAN-CONTAINER-DEBUG: %s" % " ".join(image_pull_cmd)) |
1865 | 1869 | rc, out, err = module.run_command(image_pull_cmd) |
1866 | 1870 | if rc != 0: |
1867 | 1871 | module.fail_json(msg="Can't pull image %s" % image, stdout=out, stderr=err) |
1868 | | - image_actions.append("pulled image %s" % image) |
1869 | | - return image_actions |
| 1872 | + image_actions.append("pulled image %s" % image) |
| 1873 | + return image_actions |
1870 | 1874 |
|
1871 | 1875 |
|
1872 | 1876 | class PodmanContainer: |
@@ -2102,15 +2106,21 @@ def __init__(self, module, params): |
2102 | 2106 | else: |
2103 | 2107 | self.executable = self.module.get_bin_path(self.module_params["executable"], required=True) |
2104 | 2108 | self.image = self.module_params["image"] |
2105 | | - image_actions = ensure_image_exists(self.module, self.image, self.module_params, self.client) |
2106 | | - self.results["actions"] += image_actions |
2107 | 2109 | self.state = self.module_params["state"] |
2108 | | - self.restart = self.module_params["force_restart"] |
2109 | | - self.recreate = self.module_params["recreate"] |
| 2110 | + disable_image_pull = self.state in ("quadlet", "absent") or self.module_params["pull"] == "never" |
| 2111 | + image_actions = ( |
| 2112 | + ensure_image_exists(self.module, self.image, self.module_params, self.client) |
| 2113 | + if not disable_image_pull |
| 2114 | + else [] |
| 2115 | + ) |
| 2116 | + self.results["actions"] += image_actions |
2110 | 2117 |
|
2111 | 2118 | self.restart = self.module_params["force_restart"] |
2112 | 2119 | self.recreate = self.module_params["recreate"] |
2113 | 2120 |
|
| 2121 | + if self.module_params["generate_systemd"].get("new"): |
| 2122 | + self.module_params["rm"] = True |
| 2123 | + |
2114 | 2124 | self.container = PodmanContainer(self.module, self.name, self.module_params, self.client) |
2115 | 2125 |
|
2116 | 2126 | def api_wait(self): |
|
0 commit comments