diff --git a/defaults/main.yml b/defaults/main.yml index 219d618faffa2..6b00692a96269 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,10 +1,11 @@ --- es_major_version: "1.7" -es_version: "1.7.0" +es_version: "1.7.1" es_version_lock: false es_use_repository: true es_start_service: true es_plugins_reinstall: false es_scripts: false +es_templates: false es_user: elasticsearch es_group: elasticsearch diff --git a/tasks/elasticsearch-RedHat-version-lock.yml b/tasks/elasticsearch-RedHat-version-lock.yml index 8a56872196835..e6fd8381ff207 100644 --- a/tasks/elasticsearch-RedHat-version-lock.yml +++ b/tasks/elasticsearch-RedHat-version-lock.yml @@ -2,5 +2,5 @@ - name: RedHat - install yum-version-lock yum: name=yum-plugin-versionlock state=present update_cache=yes - name: RedHat - lock elasticsearch version - command: yum versionlock add elasticsearch + shell: yum versionlock delete 0:elasticsearch* ; yum versionlock add elasticsearch{% if es_version is defined and es_version != "" %}-{{ es_version }}{% endif %} diff --git a/tasks/elasticsearch-RedHat.yml b/tasks/elasticsearch-RedHat.yml index 3363634b46bda..e256293a6a841 100644 --- a/tasks/elasticsearch-RedHat.yml +++ b/tasks/elasticsearch-RedHat.yml @@ -7,6 +7,10 @@ template: src=elasticsearch.repo dest=/etc/yum.repos.d/elasticsearch-{{ es_major_version }}.repo when: es_use_repository +- name: RedHat - include versionlock + include: elasticsearch-RedHat-version-lock.yml + when: es_version_lock + - name: RedHat - Install Elasticsearch yum: name=elasticsearch{% if es_version is defined and es_version != "" %}-{{ es_version }}{% endif %} state=present update_cache=yes when: es_use_repository diff --git a/tasks/elasticsearch-templates.yml b/tasks/elasticsearch-templates.yml new file mode 100644 index 0000000000000..26e345b0c701a --- /dev/null +++ b/tasks/elasticsearch-templates.yml @@ -0,0 +1,14 @@ +--- +- name: Copy templates to elasticsearch + copy: src=templates dest=/etc/elasticsearch/ + +- name: Wait for elasticsearch to startup + wait_for: port=9200 delay=10 + +- name: Get template files + shell: find . -maxdepth 1 -type f | sed "s#\./##" | sed "s/.json//" chdir=/etc/elasticsearch/templates + register: resultstemplate + +- name: Install template(s) + command: 'curl -sL -XPUT http://localhost:9200/_template/{{item}} -d @/etc/elasticsearch/templates/{{item}}.json' + with_items: resultstemplate.stdout_lines diff --git a/tasks/main.yml b/tasks/main.yml index f92778043e6c1..b492c29b1de37 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -3,8 +3,8 @@ - include: elasticsearch.yml - include: elasticsearch-plugins.yml when: es_plugins is defined -- include: elasticsearch-version-lock.yml - when: es_version_lock - include: elasticsearch-scripts.yml when: es_scripts +- include: elasticsearch-templates.yml + when: es_templates