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

34 lines
1.7 KiB
YAML
Raw Normal View History

2024-09-19 16:04:30 +00:00
---
- name: Ensure docker client is logged {{ (cinny_state == 'present') | ternary('in', 'out') }}
community.docker.docker_login:
registry_url: "{{ cinny_container_image_registry }}"
username: "{{ cinny_container_image_registry_username }}"
password: "{{ cinny_container_image_registry_password }}"
reauthorize: "{{ cinny_container_image_registry_reauthorize | default(omit, true) }}"
state: "{{ cinny_state }}"
when:
- cinny_container_image_registry_username | default(false, true)
- cinny_container_image_registry_password | default(false, true)
- name: Ensure container image '{{ cinny_container_image }}' is {{ cinny_state }} locally
community.docker.docker_image:
name: "{{ cinny_container_image }}"
state: "{{ cinny_state }}"
source: "{{ cinny_container_source | default('pull') }}"
force_source: "{{ cinny_container_image_tag | default(false, true) }}"
- name: Ensure container '{{ cinny_container_name }}' is {{ cinny_state }}
community.docker.docker_container:
name: "{{ cinny_container_name }}"
image: "{{ cinny_container_image }}"
state: "{{ (cinny_state == 'present') | ternary('started', 'absent') }}"
env: "{{ cinny_container_env | default(omit) }}"
user: "{{ cinny_container_user }}"
ports: "{{ cinny_container_ports | default(omit) }}"
labels: "{{ cinny_container_labels | default(omit) }}"
volumes: "{{ cinny_container_full_volumes }}"
networks: "{{ cinny_container_networks | default(omit) }}"
etc_hosts: "{{ cinny_container_etc_hosts | default(omit) }}"
restart_policy: "{{ cinny_container_restart_policy }}"
purge_networks: "{{ cinny_container_purge_networks | default(omit) }}"