Prevent Ansible errors when shield is not installed/disabled

This commit is contained in:
Maarten Bezemer 2016-11-02 15:02:51 +01:00
parent 56837b0627
commit a1d9951219

View file

@ -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