From 148c3153029a5334963decc03762977ad6367896 Mon Sep 17 00:00:00 2001 From: Amit Phulera Date: Thu, 24 Oct 2024 16:41:01 +0530 Subject: [PATCH] create data directories if they do not exist --- .../roles/elasticsearch/tasks/main.yml | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/commcare_cloud/ansible/roles/elasticsearch/tasks/main.yml b/src/commcare_cloud/ansible/roles/elasticsearch/tasks/main.yml index 79e5319de9..3f19018d2b 100644 --- a/src/commcare_cloud/ansible/roles/elasticsearch/tasks/main.yml +++ b/src/commcare_cloud/ansible/roles/elasticsearch/tasks/main.yml @@ -142,19 +142,30 @@ - debug: msg="If you're just updating the ES conf then you sill need to restart the cluster. Use the 'es_rolling_restart' playbook." when: copy_elasticsearch_conf_result.changed -- name: Create Elasticsearch data directories - become: yes - file: +- name: Check if Elasticsearch data directories exist + stat: path: "{{ item }}" - state: directory - owner: elasticsearch - group: elasticsearch - mode: 0755 + register: dir_stat with_items: - "{{ elasticsearch_data_dir }}" - "{{ elasticsearch_data_dir }}/data" - "{{ elasticsearch_data_dir }}/logs" - "{{ elasticsearch_data_dir }}/tmp" + tags: + - es_conf + +- name: Create Elasticsearch data directories if they do not exist + become: yes + file: + path: "{{ item.item }}" + state: directory + owner: elasticsearch + group: elasticsearch + mode: 0755 + when: not item.stat.exists + with_items: "{{ dir_stat.results }}" + tags: + - es_conf - name: Start Elasticsearch become: yes