Test fixes + ensuring node is started for templates

This commit is contained in:
Dale McDiarmid 2016-07-23 16:41:37 +01:00
parent ab592724d8
commit a149328ae8
10 changed files with 30 additions and 19 deletions

View file

@ -12,13 +12,16 @@
with_fileglob:
- "{{ es_templates_fileglob }}"
- name: Ensure elasticsearch is started
service: name={{instance_init_script | basename}} state=started enabled=yes
- name: Wait for elasticsearch to startup
wait_for: port={{es_api_port}} delay=10
- name: Get template files
- name: Get template files
shell: find . -maxdepth 1 -type f | sed "s#\./##" | sed "s/.json//" chdir=/etc/elasticsearch/templates
register: resultstemplate
- name: Install template(s)
command: "curl -sL -XPUT http://{{es_api_host}}:{{es_api_port}}/_template/{{item}} -d @/etc/elasticsearch/templates/{{item}}.json"
with_items: "{{ resultstemplate.stdout_lines }}"
with_items: "{{ resultstemplate.stdout_lines }}"

View file

@ -10,8 +10,9 @@
shell: cat {{conf_dir}}/shield/users | awk -F':' '{print $1}'
register: current_file_users
when: manage_file_users
changed_when: False
- set_fact: users_to_remove={{ current_file_users.stdout_lines | difference ( es_users.file.keys() ) }}
- set_fact: users_to_remove={{ current_file_users.stdout_lines | difference (es_users.file.keys()) }}
when: manage_file_users
#Remove users
@ -25,12 +26,15 @@
ES_HOME: "{{es_home}}"
- set_fact: users_to_add={{ es_users.file.keys() | difference (current_file_users.stdout_lines) }}
when: manage_file_users
#Add users
- name: Add Users
command: >
{{es_home}}/bin/shield/esusers useradd {{item.key}} -p {{item.value.password}}
with_dict: "{{es_users.file}}"
when: manage_file_users and es_users.file.keys() | length > 0
{{es_home}}/bin/shield/esusers useradd {{item}} -p {{es_users.file[item].password}}
with_items: "{{users_to_add}}"
when: manage_file_users and users_to_add | length > 0
environment:
CONF_DIR: "{{ conf_dir }}"
ES_HOME: "{{es_home}}"
@ -41,6 +45,8 @@
{{es_home}}/bin/shield/esusers passwd {{item.key}} -p {{item.value.password}}
with_dict: "{{es_users.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
environment:
CONF_DIR: "{{ conf_dir }}"
ES_HOME: "{{es_home}}"

View file

@ -26,11 +26,6 @@
#TODO: 1. Skip users with no password defined or error 2. Passwords | length > 6
#Ensure shield conf directory is created
- name: Ensure shield conf directory exists
file: path={{ conf_dir }}/shield state=directory owner={{ es_user }} group={{ es_group }}
#-----------------------------FILE BASED REALM----------------------------------------
- include: elasticsearch-shield-file.yml
@ -43,3 +38,7 @@
when: (es_users is defined and es_users.native is defined) or (es_roles is defined and es_roles.native is defined)
#Ensure shield conf directory is created
- name: Ensure shield conf directory exists
file: path={{ conf_dir }}/shield state=directory owner={{ es_user }} group={{ es_group }}
changed_when: False