From a1d995121982428533a1e7bf4557015b03120ca9 Mon Sep 17 00:00:00 2001 From: Maarten Bezemer Date: Wed, 2 Nov 2016 15:02:51 +0100 Subject: [PATCH] Prevent Ansible errors when shield is not installed/disabled --- tasks/xpack/shield/elasticsearch-shield-file.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks/xpack/shield/elasticsearch-shield-file.yml b/tasks/xpack/shield/elasticsearch-shield-file.yml index da78e91..99755cc 100644 --- a/tasks/xpack/shield/elasticsearch-shield-file.yml +++ b/tasks/xpack/shield/elasticsearch-shield-file.yml @@ -16,7 +16,7 @@ command: > {{es_home}}/bin/shield/esusers userdel {{item}} when: manage_file_users and (users_to_remove | length > 0) - with_items: "{{users_to_remove}}" + with_items: "{{users_to_remove | default([])}}" environment: CONF_DIR: "{{ conf_dir }}" ES_HOME: "{{es_home}}" @@ -29,7 +29,7 @@ - name: Add Users command: > {{es_home}}/bin/shield/esusers useradd {{item}} -p {{es_users.file[item].password}} - with_items: "{{users_to_add}}" + with_items: "{{users_to_add | default([])}}" when: manage_file_users and users_to_add | length > 0 environment: CONF_DIR: "{{ conf_dir }}" @@ -39,7 +39,7 @@ - name: Set User Passwords command: > {{es_home}}/bin/shield/esusers passwd {{item.key}} -p {{item.value.password}} - with_dict: "{{es_users.file}}" + with_dict: "{{(es_users | default({'file':{}})).file}}" when: manage_file_users and es_users.file.keys() | length > 0 #Currently no easy way to figure out if the password has changed or to know what it currently is so we can skip. changed_when: False