matrix/roles/element/tasks/deploy-docker.yml

34 lines
1.7 KiB
YAML
Raw Normal View History

2024-09-19 16:04:57 +00:00
---
- name: Ensure docker client is logged {{ (element_state == 'present') | ternary('in', 'out') }}
community.docker.docker_login:
registry_url: "{{ element_container_image_registry }}"
username: "{{ element_container_image_registry_username }}"
password: "{{ element_container_image_registry_password }}"
reauthorize: "{{ element_container_image_registry_reauthorize | default(omit, true) }}"
state: "{{ element_state }}"
when:
- element_container_image_registry_username | default(false, true)
- element_container_image_registry_password | default(false, true)
- name: Ensure container image '{{ element_container_image }}' is {{ element_state }} locally
community.docker.docker_image:
name: "{{ element_container_image }}"
state: "{{ element_state }}"
source: "{{ element_container_source }}"
force_source: "{{ element_container_image_tag | default(false, true) }}"
- name: Ensure container '{{ element_container_name }}' is {{ element_state }}
community.docker.docker_container:
name: "{{ element_container_name }}"
image: "{{ element_container_image }}"
state: "{{ (element_state == 'present') | ternary('started', 'absent') }}"
env: "{{ element_container_env | default(omit) }}"
user: "{{ element_container_user }}"
ports: "{{ element_container_ports | default(omit) }}"
labels: "{{ element_container_labels | default(omit) }}"
volumes: "{{ element_container_full_volumes }}"
networks: "{{ element_container_networks | default(omit) }}"
etc_hosts: "{{ element_container_etc_hosts | default(omit) }}"
restart_policy: "{{ element_container_restart_policy }}"
purge_networks: "{{ element_container_purge_networks | default(omit) }}"