Compare commits
4 Commits
597faa3fd5
...
abf3859af7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
abf3859af7 | ||
|
|
bdec55ffc7 | ||
|
|
2712cf2865 | ||
|
|
c5fb7f599c |
@@ -11,6 +11,3 @@ container_auto_start: true
|
||||
container_auto_update: true
|
||||
container_requires: []
|
||||
container_wants: []
|
||||
container_image_creds:
|
||||
username: ""
|
||||
password: ""
|
||||
|
||||
@@ -23,22 +23,6 @@ argument_specs:
|
||||
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.
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
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 }}
|
||||
@@ -41,7 +40,7 @@
|
||||
ansible.builtin.include_tasks: secrets.yaml
|
||||
when: container_secrets | length > 0
|
||||
|
||||
- name: Create container service {{ container_name }}
|
||||
- name: Create container {{ container_name }}
|
||||
containers.podman.podman_container:
|
||||
image: "{{ _container_image }}"
|
||||
name: "{{ container_name }}"
|
||||
@@ -52,6 +51,7 @@
|
||||
publish: "{{ container_publish_ports }}"
|
||||
secrets: "{{ _container_secrets }}"
|
||||
env: "{{ container_env }}"
|
||||
label: "{{ _container_labels if _container_labels | length > 0 else omit }}"
|
||||
state: quadlet
|
||||
quadlet_file_mode: "0600"
|
||||
quadlet_options: "{{ _container_quadlet_options }}"
|
||||
|
||||
@@ -68,6 +68,15 @@ _container_secrets: >-
|
||||
| map('join', ',')
|
||||
}}
|
||||
|
||||
_container_labels: >-
|
||||
{{
|
||||
{'io.containers.autoupdate.authfile': '/etc/containers/auth.json'}
|
||||
if container_auto_update and
|
||||
container_image.split('/')[0] in
|
||||
podman_registry_accounts | map(attribute='registry')
|
||||
else {}
|
||||
}}
|
||||
|
||||
_container_quadlet_unit_options: |
|
||||
[Unit]
|
||||
Description=Container {{ container_name }}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
---
|
||||
image_creds:
|
||||
username: ""
|
||||
password: ""
|
||||
@@ -9,19 +9,3 @@ argument_specs:
|
||||
description: "The image FQIN (format registry/imagename:tag)"
|
||||
type: str
|
||||
required: true
|
||||
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
|
||||
|
||||
@@ -6,9 +6,14 @@
|
||||
- name: Create container image service {{ image_name }}
|
||||
containers.podman.podman_image:
|
||||
name: "{{ image_name }}"
|
||||
username: "{{ image_creds.username if image_creds.username | length > 0 else omit }}"
|
||||
password: "{{ image_creds.password if image_creds.password | length > 0 else omit }}"
|
||||
state: quadlet
|
||||
quadlet_filename: "{{ image_name | replace('/', '_') }}"
|
||||
quadlet_file_mode: "0600"
|
||||
quadlet_options: >-
|
||||
{{
|
||||
['AuthFile=/etc/containers/auth.json']
|
||||
if image_name.split('/')[0] in
|
||||
podman_registry_accounts | map(attribute='registry')
|
||||
else []
|
||||
}}
|
||||
notify: Reload systemd daemon
|
||||
|
||||
2
roles/podman/defaults/main.yaml
Normal file
2
roles/podman/defaults/main.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
---
|
||||
podman_registry_accounts: []
|
||||
@@ -2,4 +2,23 @@
|
||||
argument_specs:
|
||||
main:
|
||||
description: Installs podman
|
||||
options: {}
|
||||
options:
|
||||
podman_registry_accounts:
|
||||
description: Dict of accounts for container repositories
|
||||
type: list
|
||||
required: false
|
||||
default: []
|
||||
elements: dict
|
||||
options:
|
||||
registry:
|
||||
description: Registry server to login to
|
||||
type: str
|
||||
required: true
|
||||
username:
|
||||
description: Username
|
||||
type: str
|
||||
required: true
|
||||
password:
|
||||
description: Password / token
|
||||
type: str
|
||||
required: true
|
||||
|
||||
@@ -10,3 +10,12 @@
|
||||
name: podman-auto-update.timer
|
||||
state: started
|
||||
enabled: true
|
||||
|
||||
- name: Login to registries
|
||||
containers.podman.podman_login:
|
||||
registry: "{{ item.registry }}"
|
||||
username: "{{ item.username }}"
|
||||
password: "{{ item.password }}"
|
||||
authfile: /etc/containers/auth.json
|
||||
loop: "{{ podman_registry_accounts }}"
|
||||
no_log: true
|
||||
|
||||
@@ -27,7 +27,3 @@ service_additional_containers: []
|
||||
service_requires: []
|
||||
service_wants: []
|
||||
service_auto_update: true
|
||||
|
||||
service_container_image_creds:
|
||||
username: ""
|
||||
password: ""
|
||||
|
||||
@@ -66,22 +66,6 @@ argument_specs:
|
||||
description: "The image to run in the service container(s), in FQIN format (registry/imagename:tag)."
|
||||
type: str
|
||||
required: true
|
||||
service_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
|
||||
|
||||
service_container_user:
|
||||
description: The UID to run as inside the container
|
||||
@@ -150,6 +134,11 @@ argument_specs:
|
||||
type: str
|
||||
required: false
|
||||
default: ""
|
||||
mode:
|
||||
description: Templated file permissions
|
||||
type: str
|
||||
required: false
|
||||
default: "0644"
|
||||
volume_device:
|
||||
description: >-
|
||||
The path of a device which is mounted for the volume.
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
vars:
|
||||
container_name: "{{ _service_additional_container.name }}"
|
||||
container_image: "{{ _service_additional_container.image | default(service_container_image) }}"
|
||||
container_image_creds: "{{ service_container_image_creds }}"
|
||||
container_command: "{{ _service_additional_container.command | default([]) }}"
|
||||
container_user: "{{ service_container_user }}"
|
||||
container_mounts: "{{ _service_additional_container_mounts }}"
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
vars:
|
||||
container_name: "{{ service_name }}"
|
||||
container_image: "{{ service_container_image }}"
|
||||
container_image_creds: "{{ service_container_image_creds }}"
|
||||
container_command: "{{ service_container_command }}"
|
||||
container_user: "{{ service_container_user }}"
|
||||
container_mounts: "{{ _service_container_mounts }}"
|
||||
|
||||
@@ -22,6 +22,6 @@
|
||||
ansible.builtin.template:
|
||||
src: "{{ item[0].source }}"
|
||||
dest: "{{ item[1] }}"
|
||||
mode: "0644"
|
||||
mode: "{{ item[0].mode | default('0644') }}"
|
||||
notify: Restart container service {{ service_name }}
|
||||
loop: "{{ _service_all_template_mounts | zip(_service_all_template_mount_host_files) }}"
|
||||
|
||||
@@ -39,12 +39,13 @@ _service_additional_container_template_mounts: >-
|
||||
{{
|
||||
([{'readonly': true}] * _service_additional_template_mounts | length) |
|
||||
zip(
|
||||
_service_additional_template_mounts,
|
||||
_service_additional_template_mounts |
|
||||
map(attribute='source') |
|
||||
map('regex_replace', '\.j2$', '') |
|
||||
map('regex_replace', '^', _service_host_directory ~ '/mounts/') |
|
||||
map('community.general.dict_kv', 'source'),
|
||||
community.general.remove_keys(['mode']),
|
||||
_service_additional_template_mounts |
|
||||
map(attribute='source') |
|
||||
map('regex_replace', '\.j2$', '') |
|
||||
map('regex_replace', '^', _service_host_directory ~ '/mounts/') |
|
||||
map('community.general.dict_kv', 'source'),
|
||||
([{'type': 'bind'}] * _service_additional_template_mounts | length)
|
||||
) |
|
||||
map('combine')
|
||||
|
||||
@@ -19,12 +19,13 @@ _service_container_template_mounts: >-
|
||||
{{
|
||||
([{'readonly': true}] * _service_template_mounts | length) |
|
||||
zip(
|
||||
_service_template_mounts,
|
||||
_service_template_mounts |
|
||||
map(attribute='source') |
|
||||
map('regex_replace', '\.j2$', '') |
|
||||
map('regex_replace', '^', _service_host_directory ~ '/mounts/') |
|
||||
map('community.general.dict_kv', 'source'),
|
||||
community.general.remove_keys(['mode']),
|
||||
_service_template_mounts |
|
||||
map(attribute='source') |
|
||||
map('regex_replace', '\.j2$', '') |
|
||||
map('regex_replace', '^', _service_host_directory ~ '/mounts/') |
|
||||
map('community.general.dict_kv', 'source'),
|
||||
([{'type': 'bind'}] * _service_template_mounts | length)
|
||||
) |
|
||||
map('combine')
|
||||
|
||||
Reference in New Issue
Block a user