---
- name: Ensure container image '{{ cinny_container_image }}' is {{ cinny_state }} locally
  containers.podman.podman_image:
    name: "{{ cinny_container_image }}"
    state: "{{ cinny_state }}"
    pull: "{{ cinny_container_source == 'pull' }}"
    force: "{{ cinny_container_image_tag | default(false, true) }}"

- name: Ensure container '{{ cinny_container_name }}' is {{ cinny_state }}
  containers.podman.podman_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 }}"
    network: "{{ cinny_container_networks | default(omit) }}"
    hostname: "{{ cinny_container_hostname | default(omit) }}"
    etc_hosts: "{{ cinny_container_etc_hosts | default(omit) }}"
    restart_policy: "{{ cinny_container_restart_policy }}"