--- - name: Ensure postgresql container image '{{ postgresql_container_image }}' is {{ postgresql_state }} community.docker.docker_image: name: "{{ postgresql_container_image }}" state: "{{ postgresql_state }}" source: "{{ postgresql_container_image_source }}" force_source: "{{ postgresql_container_image_force_source }}" register: postgresql_container_image_info until: postgresql_container_image_info is success retries: 5 delay: 4 - name: Ensure /etc/passwd for container is {{ postgresql_state }} ansible.builtin.template: src: "postgresql-passwd.j2" dest: "{{ postgresql_container_passwd_file }}" owner: "{{ postgresql_user_id }}" group: "{{ postgresql_user_group_id }}" mode: "0640" when: postgresql_state == 'present' - name: Initialize database if empty ansible.builtin.include_tasks: file: "initialize-docker.yml" when: - postgresql_state == 'present' - name: Ensure postgresql container '{{ postgresql_container_name }}' is {{ postgresql_container_state }} community.docker.docker_container: name: "{{ postgresql_container_name }}" image: "{{ postgresql_container_image }}" env: "{{ postgresql_container_env | default(omit, true) }}" user: "{{ postgresql_container_user | default(omit, true) }}" ports: "{{ postgresql_container_ports | default(omit, true) }}" labels: "{{ postgresql_container_labels | default(omit, true) }}" volumes: "{{ postgresql_container_merged_volumes }}" recreate: "{{ postgresql_container_recreate | default(omit, true) }}" networks: "{{ postgresql_container_networks | default(omit, true) }}" etc_hosts: "{{ postgresql_container_etc_hosts | default(omit, true) }}" memory: "{{ postgresql_container_memory | default(omit, true) }}" memory_reservation: "{{ postgresql_container_memory_reservation | default(omit, true) }}" oom_killer: "{{ postgresql_container_oom_killer | default(omit, true) }}" oom_score_adj: "{{ postgresql_container_oom_score_adj | default(omit, true) }}" shm_size: "{{ postgresql_container_shm_size | default(omit, true) }}" ulimits: "{{ postgresql_container_ulimits | default(omit, true) }}" restart_policy: "{{ postgresql_container_restart_policy | default(omit, true) }}" state: "{{ postgresql_container_state }}"