I've just started to learn Ansible. I have the following tasks defined in a role for installing elasticsearch.
---
- name: install elasticsearch
homebrew: name=elasticsearch state=present
- command: brew --prefix elasticsearch
register: elasticsearch_home
- name: install elasticsearch-head
command: "{{ elasticsearch_home.stdout }}/bin/plugin --install mobz/elasticsearch-head"
- name: install elasticsearch-analysis-icu
command: "{{ elasticsearch_home.stdout }}/bin/plugin --install elasticsearch/elasticsearch-analysis-icu/2.2.0"
- name: install elasticsearch-inquisitor
command: "{{ elasticsearch_home.stdout }}/bin/plugin --install polyfractal/elasticsearch-inquisitor"
And I get the following error when running my playbook.
PLAY [all] ********************************************************************
GATHERING FACTS ***************************************************************
ok: [localhost]
TASK: [java | install latest java] ********************************************
ok: [localhost]
TASK: [elasticsearch | install elasticsearch] *********************************
ok: [localhost]
TASK: [elasticsearch | command brew --prefix elasticsearch] *******************
changed: [localhost]
TASK: [elasticsearch | install elasticsearch-head] ****************************
failed: [localhost] => {"changed": true, "cmd": "/usr/local/opt/elasticsearch/bin/plugin --install mobz/elasticsearch-head", "delta": "0:00:00.264923", "end": "2015-03-21 21:18:36.863296", "rc": 1, "start": "2015-03-21 21:18:36.598373", "warnings": []}
stderr: Exception in thread "main" org.elasticsearch.common.settings.SettingsException: Failed to load settings from [file:/Users/<username>/elasticsearch.yml]
at org.elasticsearch.common.settings.ImmutableSettings$Builder.loadFromStream(ImmutableSettings.java:947)
at org.elasticsearch.common.settings.ImmutableSettings$Builder.loadFromUrl(ImmutableSettings.java:931)
at org.elasticsearch.node.internal.InternalSettingsPreparer.prepareSettings(InternalSettingsPreparer.java:77)
at org.elasticsearch.plugins.PluginManager.main(PluginManager.java:389)
Caused by: org.elasticsearch.ElasticsearchParseException: malformed, expected settings to start with 'object', instead was [START_ARRAY]
at org.elasticsearch.common.settings.loader.XContentSettingsLoader.load(XContentSettingsLoader.java:65)
at org.elasticsearch.common.settings.loader.XContentSettingsLoader.load(XContentSettingsLoader.java:45)
at org.elasticsearch.common.settings.loader.YamlSettingsLoader.load(YamlSettingsLoader.java:46)
at org.elasticsearch.common.settings.ImmutableSettings$Builder.loadFromStream(ImmutableSettings.java:944)
... 3 more
FATAL: all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
to retry, use: --limit @/Users/<username>/elasticsearch.retry
localhost : ok=4 changed=1 unreachable=0 failed=1
At first I thought it might be a bug in the plugin installer that was incorrectly handling the case where the plugin was already installed. I uninstalled the plugin and then ran the plays again, but I received the exact same error. I also tried using shell
instead of command
, but there was no difference in result.
stderr: Exception in thread "main" org.elasticsearch.common.settings.SettingsException: Failed to load settings from [file:/Users/<username>/elasticsearch.yml]
This line makes me think that elasticsearch is not receiving some configurations correctly. But I don't understand why it would expect to get information from the yml file. Even if there was some feature that allowed for piping settings into the elasticsearch plugin installer, I would expect that using Ansible's shell
module would execute the command in a separate shell and therefore elasticsearch would have no clue about the yml file or Ansible. Any ideas?