From d36f1dd497722cb31ca56295b31e7abfb3e1df6c Mon Sep 17 00:00:00 2001 From: Jonathan Strootman Date: Wed, 9 Mar 2016 16:45:23 -0700 Subject: [PATCH 1/2] Added `with_fileglob` loop to script and template This allows the user to set the `es_template_fileglob` or `es_scripts_fileglob` variables in order to specify a directory of index templates or scripts. Issue #57 --- tasks/elasticsearch-scripts.yml | 3 ++- tasks/elasticsearch-templates.yml | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tasks/elasticsearch-scripts.yml b/tasks/elasticsearch-scripts.yml index 546ed19..6d7d297 100644 --- a/tasks/elasticsearch-scripts.yml +++ b/tasks/elasticsearch-scripts.yml @@ -10,4 +10,5 @@ when: es_config['path.scripts'] is defined - name: Copy scripts to elasticsearch - copy: src=scripts dest={{ es_script_dir }} owner={{ es_user }} group={{ es_group }} \ No newline at end of file + copy: src={{ item }} dest={{ es_script_dir }} owner={{ es_user }} group={{ es_group }} + with_fileglob: es_scripts_fileglob | default("scripts") diff --git a/tasks/elasticsearch-templates.yml b/tasks/elasticsearch-templates.yml index 1bcfd71..ba46fd8 100644 --- a/tasks/elasticsearch-templates.yml +++ b/tasks/elasticsearch-templates.yml @@ -1,7 +1,8 @@ --- - name: Copy templates to elasticsearch - copy: src=templates dest=/etc/elasticsearch/ owner={{ es_user }} group={{ es_group }} + copy: src={{ item }} dest=/etc/elasticsearch/ owner={{ es_user }} group={{ es_group }} + with_fileglob: es_templates_fileglob | default("templates") - set_fact: http_port=9200 @@ -17,4 +18,4 @@ - name: Install template(s) command: "curl -sL -XPUT http://localhost:{{http_port}}/_template/{{item}} -d @/etc/elasticsearch/templates/{{item}}.json" - with_items: resultstemplate.stdout_lines \ No newline at end of file + with_items: resultstemplate.stdout_lines From cea242ff3c77827140209f97da53af0063d72baa Mon Sep 17 00:00:00 2001 From: Jonathan Strootman Date: Wed, 9 Mar 2016 16:49:10 -0700 Subject: [PATCH 2/2] Updated README for template/script fileglobs Issue #57 --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 2926bb4..1a95b7f 100644 --- a/README.md +++ b/README.md @@ -188,6 +188,10 @@ controlled by the following parameters: * ```es_work_dir``` - defaults to "/tmp/elasticsearch". * ```es_plugin_dir``` - defaults to "/usr/share/elasticsearch/plugins". +This role ships with sample scripts and templates located in the [files/scripts/](files/scripts) and [files/templates/](files/templates) directories, respectively. These variables are used with the Ansible [with_fileglob](http://docs.ansible.com/ansible/playbooks_loops.html#id4) loop. When setting the globs, be sure to use an absolute path. +* ```es_scripts_fileglob``` - defaults to `/files/scripts/`. +* ```es_templates_fileglob``` - defaults to `/files/templates/`. + ## Notes * The role assumes the user/group exists on the server. The elasticsearch packages create the default elasticsearch user. If this needs to be changed, ensure the user exists.