Dodge deprecation warnings in plugin and template install by working as per http://docs.ansible.com/ansible/playbooks_conditionals.html#loops-and-conditionals

This commit is contained in:
Johan De Meersman 2016-08-17 16:09:50 +02:00
parent f8e140708a
commit 0d095aeea3
2 changed files with 6 additions and 7 deletions

View file

@ -27,7 +27,7 @@
- name: Remove elasticsearch plugins
command: "{{es_home}}/bin/plugin remove {{item}} --silent"
ignore_errors: yes
with_items: "{{ installed_plugins.stdout_lines }}"
with_items: "{{ installed_plugins.stdout_lines | default([]) }}"
when: es_plugins_reinstall and installed_plugins.stdout_lines | length > 0 and not 'No plugin detected' in installed_plugins.stdout_lines[0]
notify: restart elasticsearch
environment:
@ -41,8 +41,8 @@
register: plugin_installed
failed_when: "'ERROR' in plugin_installed.stdout"
changed_when: plugin_installed.rc == 0
with_items: "{{ es_plugins }}"
when: es_plugins is defined and not es_plugins is none and es_plugins_reinstall
with_items: "{{ es_plugins | default([]) }}"
when: not es_plugins is none and es_plugins_reinstall
notify: restart elasticsearch
environment:
CONF_DIR: "{{ conf_dir }}"

View file

@ -8,9 +8,8 @@
- name: Copy templates to elasticsearch
copy: src={{ item }} dest=/etc/elasticsearch/templates owner={{ es_user }} group={{ es_group }}
when: es_templates_fileglob is defined
with_fileglob:
- "{{ es_templates_fileglob }}"
- "{{ es_templates_fileglob | default('') }}"
- set_fact: http_port=9200
tags:
@ -30,4 +29,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 }}"
with_items: "{{ resultstemplate.stdout_lines | default([]) }}"