2017-01-11 13:02:23 +00:00
---
#Security specific configuration done here
#TODO: 1. Skip users with no password defined or error 2. Passwords | length > 6
2017-04-18 13:26:16 -04:00
#Ensure x-pack conf directory is created if necessary
- name : Ensure x-pack conf directory exists (file)
file : path={{ conf_dir }}/x-pack state=directory owner={{ es_user }} group={{ es_group }}
changed_when : False
when :
2018-02-16 16:37:00 -05:00
- es_enable_xpack and "security" in es_xpack_features
2017-09-19 12:21:46 +01:00
- (es_users is defined and es_users.file is defined) or (es_roles is defined and es_roles.file is defined) or (es_role_mapping is defined)
2017-04-18 13:26:16 -04:00
2018-01-08 16:59:44 -08:00
#-----------------------------Create Bootstrap User-----------------------------------
- name : Check if bootstrap password is set
command : >
{{es_home}}/bin/elasticsearch-keystore list
register : list_keystore
2018-01-31 13:03:51 +01:00
changed_when : False
2018-01-08 16:59:44 -08:00
environment :
ES_PATH_CONF : "{{ conf_dir }}"
2018-01-10 09:49:24 -08:00
when :
2018-02-16 16:37:00 -05:00
- (es_enable_xpack and "security" in es_xpack_features) and (es_version | version_compare('6.0.0', '>'))
2018-01-08 16:59:44 -08:00
- name : Create Bootstrap password for elastic user
shell : echo "{{es_api_basic_auth_password}}" | {{es_home}}/bin/elasticsearch-keystore add -x 'bootstrap.password'
when :
2018-02-16 16:37:00 -05:00
- (es_enable_xpack and "security" in es_xpack_features) and (es_version | version_compare('6.0.0', '>')) and es_api_basic_auth_username is defined and list_keystore is defined and es_api_basic_auth_username == 'elastic' and 'bootstrap.password' not in list_keystore.stdout_lines
2018-01-08 16:59:44 -08:00
environment :
ES_PATH_CONF : "{{ conf_dir }}"
no_log : true
2017-01-11 13:02:23 +00:00
#-----------------------------FILE BASED REALM----------------------------------------
- include : elasticsearch-security-file.yml
2018-02-16 16:37:00 -05:00
when : (es_enable_xpack and "security" in es_xpack_features) and ((es_users is defined and es_users.file is defined) or (es_roles is defined and es_roles.file is defined))
2017-01-11 13:02:23 +00:00
#-----------------------------ROLE MAPPING ----------------------------------------
#Copy Roles files
- name : Copy role_mapping.yml File for Instance
2017-05-12 13:31:50 -07:00
become : yes
2017-01-11 13:02:23 +00:00
template : src=security/role_mapping.yml.j2 dest={{conf_dir}}/x-pack/role_mapping.yml owner={{ es_user }} group={{ es_group }} mode=0644 force=yes
when : es_role_mapping is defined
#-----------------------------AUTH FILE----------------------------------------
- name : Copy message auth key to elasticsearch
2017-05-12 13:31:50 -07:00
become : yes
2017-01-11 13:02:23 +00:00
copy : src={{ es_message_auth_file }} dest={{conf_dir}}/x-pack/system_key owner={{ es_user }} group={{ es_group }} mode=0600 force=yes
when : es_message_auth_file is defined
#------------------------------------------------------------------------------------
#Ensure security conf directory is created
- name : Ensure security conf directory exists
2017-05-12 13:31:50 -07:00
become : yes
2017-01-11 13:02:23 +00:00
file : path={{ conf_dir }}/security state=directory owner={{ es_user }} group={{ es_group }}
changed_when : False
2018-02-16 16:37:00 -05:00
when : es_enable_xpack and "security" in es_xpack_features