Add image role, support logging in to registries

This commit is contained in:
uumas
2025-04-10 19:27:16 +03:00
parent 093e7846ad
commit 3ac6b98a30
11 changed files with 105 additions and 5 deletions

View File

@@ -10,3 +10,6 @@ container_auto_start: true
container_auto_update: true
container_requires: []
container_wants: []
container_image_creds:
username: ""
password: ""

View File

@@ -7,10 +7,6 @@ argument_specs:
description: Name of the container. Must be unique within a host.
type: str
required: true
container_image:
description: "The image to run in the container, in FQIN format (registry/imagename:tag)"
type: str
required: true
container_command:
description: Command to start the container with.
type: list
@@ -23,6 +19,27 @@ argument_specs:
required: false
default: ""
container_image:
description: "The image to run in the container, in FQIN format (registry/imagename:tag)"
type: str
required: true
container_image_creds:
description: Credentials used to authenticate with the registry
type: dict
required: false
default:
username: ""
password: ""
options:
username:
description: Username
type: str
required: true
password:
description: Password
type: str
required: true
container_mounts:
description: List of bind mounts or volumes to be mounted inside the container.
type: list

View File

@@ -2,6 +2,14 @@
- name: Validate inputs
ansible.builtin.import_tasks: validation.yaml
- name: Create image for container {{ container_name }}
ansible.builtin.include_role:
name: image
vars:
image_name: "{{ container_image }}"
image_creds: "{{ container_image_creds }}"
when: image_created_images is not defined or container_image not in image_created_images
- name: Create networks for container {{ container_name }}
ansible.builtin.include_role:
name: network
@@ -29,7 +37,7 @@
- name: Create container service {{ container_name }}
containers.podman.podman_container:
image: "{{ container_image }}"
image: "{{ _container_image }}"
name: "{{ container_name }}"
command: "{{ container_command or omit }}"
user: "{{ container_user or omit }}"

View File

@@ -1,4 +1,6 @@
---
_container_image: "{{ container_image | replace('/', '_') ~ '.image' }}"
_container_volumes: "{{ container_mounts | selectattr('type', '==', 'volume') }}"
_container_mount_sources: "{{ container_mounts | map(attribute='source') }}"