--- - name: Check if state is valid ansible.builtin.fail: msg: >-2 Unsupported state '{{ elasticsearch_state }}'. Supported states are {{ elasticsearch_states | join(', ') }}. when: elasticsearch_state not in elasticsearch_states - name: Ensure host directories are {{ elasticsearch_state }} ansible.builtin.file: path: "{{ item }}" state: directory mode: "0777" loop: - "{{ elasticsearch_base_path }}" - "{{ elasticsearch_data_path }}" - name: Ensure elasticsearch container image '{{ elasticsearch_container_image }}' is {{ elasticsearch_state }} community.docker.docker_image: name: "{{ elasticsearch_container_image }}" state: "{{ elasticsearch_state }}" source: "{{ elasticsearch_container_image_source }}" force_source: "{{ elasticsearch_container_image_force_source }}" force_source: "{{ elasticsearch_container_image_tag|default(false, true)|bool }}" - name: Ensure elasticsearch container '{{ elasticsearch_container_name }}' is {{ elasticsearch_container_state }} community.docker.docker_container: name: "{{ elasticsearch_container_name }}" image: "{{ elasticsearch_container_image }}" env: "{{ elasticsearch_container_env | default(omit, True) }}" user: "{{ elasticsearch_container_user | default(omit, True) }}" ports: "{{ elasticsearch_container_ports | default(omit, True) }}" labels: "{{ elasticsearch_container_labels | default(omit, True) }}" volumes: "{{ elasticsearch_container_volumes }}" ulimits: "{{ elasticsearch_container_ulimits }}" networks: "{{ elasticsearch_container_networks | default(omit, True) }}" purge_networks: "{{ elasticsearch_container_purge_networks | default(omit, True) }}" restart_policy: "{{ elasticsearch_container_restart_policy }}" state: "{{ elasticsearch_container_state }}"