---
- name: Ensure container image '{{ synapse_container_image }}' is {{ synapse_state }} on host
  containers.podman.podman_image:
    name: "{{ synapse_container_image }}"
    state: "{{ synapse_state }}"
    pull: "{{ synapse_container_image_source == 'pull' }}"
    force: "{{ synapse_container_image_tag | default(false, true) | bool }}"
  register: synapse_container_image_info
  until: synapse_container_image_info is success
  retries: 5
  delay: 3

- name: Ensure synapse container '{{ synapse_container_name }}' is {{ synapse_container_state }}
  containers.podman.podmain_container:
    name: "{{ synapse_container_name }}"
    image: "{{ synapse_container_image }}"
    env: "{{ synapse_container_env | default(omit, true) }}"
    user: "{{ synapse_container_user | default(omit, true) }}"
    groups: "{{ synapse_container_groups | default(omit, true) }}"
    ports: "{{ synapse_container_ports | default(omit, true) }}"
    labels: "{{ synapse_container_labels | default(omit, true) }}"
    ulimits: "{{ synapse_container_ulimits | default(omit, true) }}"
    volumes: "{{ synapse_container_all_volumes }}"
    network: "{{ synapse_container_networks | default(omit, true) }}"
    dns_servers: "{{ synapse_container_dns_servers | default(omit, true) }}"
    etc_hosts: "{{ synapse_container_etc_hosts | default(omit, true) }}"
    memory: "{{ synapse_container_memory | default(omit, true) }}"
    memory_reservation: "{{ synapse_container_memory_reservation | default(omit, true) }}"
    memory_swap: "{{ synapse_container_memory_swap | default(omit, true) }}"
    restart_policy: "{{ synapse_container_restart_policy }}"
    state: "{{ synapse_container_state }}"