I've re-enabled x-pack, added logger.org.elasticsearch.xpack.security.authz.store.NativeRolesStore: DEBUG
in config and redeployed the cluster. First thing I noticed is that I could no longer authenticate - it seem that once .security
index gets created (first time I rolled x-pack out) and x-pack is subsequently turned off and then re-enabled it somehow confuses the system. I had to disable x-pack again to skip auth and drop .security
index and followed up with redeployment of x-pack enabled version - this allowed me to authenticate with default elastic
user again.
I subsequently performed all the checks as per your instructions above, and can confirm that
- All nodes in the cluster run the same version
5.1.1
.
_meta.security-version
for both security-index-template
template and .security
index mappings have same version matching cluster nodes: 5.1.1
.
Next, attempt to create a new role appeared to be successful this time:
curl -XPOST -k -u elastic:changeme https://elasticsearch:9200/_xpack/security/role/test_role -d '
{ "cluster": ["monitor"],
"indices": [
{
"names": [ "*" ],
"privileges": ["monitor", "delete_index"]
}
]
}'
result:
{"role":{"created":true}}
And corresponding Elasticsearch logs:
[2017-07-27T21:38:44,405][INFO ][o.e.c.m.MetaDataCreateIndexService] [es-master-0] [.security] creating index, cause [auto(index api)], templates [security-index-template, template_2, template_1], shards [1]/[0], mappings [kubernetes, role, reserved-user, user]
[2017-07-27T21:38:44,765][DEBUG][o.e.x.s.a.s.NativeRolesStore] [es-master-0] mapping for security index not up to date, so service cannot start
[2017-07-27T21:38:44,828][DEBUG][o.e.x.s.a.s.NativeRolesStore] [es-master-0] mapping for security index not up to date, so service cannot start
[2017-07-27T21:38:44,841][INFO ][o.e.c.m.MetaDataUpdateSettingsService] [es-master-0] updating number_of_replicas to [9] for indices [.security]
[2017-07-27T21:38:44,983][DEBUG][o.e.x.s.a.s.NativeRolesStore] [es-master-0] mapping for security index not up to date, so service cannot start
[2017-07-27T21:38:45,053][DEBUG][o.e.x.s.a.s.NativeRolesStore] [es-master-0] mapping for security index not up to date, so service cannot start
[2017-07-27T21:38:45,113][DEBUG][o.e.x.s.a.s.NativeRolesStore] [es-master-0] mapping for security index not up to date, so service cannot start
[2017-07-27T21:38:45,181][DEBUG][o.e.x.s.a.s.NativeRolesStore] [es-master-0] mapping for security index not up to date, so service cannot start
[2017-07-27T21:38:45,272][DEBUG][o.e.x.s.a.s.NativeRolesStore] [es-master-0] mapping for security index not up to date, so service cannot start
[2017-07-27T21:38:45,274][DEBUG][o.e.x.s.a.s.NativeRolesStore] [es-master-0] invalidating role [test_role] in cache
[2017-07-27T21:38:45,464][DEBUG][o.e.x.s.a.s.NativeRolesStore] [es-master-0] mapping for security index not up to date, so service cannot start
[2017-07-27T21:38:45,511][DEBUG][o.e.x.s.a.s.NativeRolesStore] [es-master-0] mapping for security index not up to date, so service cannot start
...
Listing of all roles returned expected results:
curl -k -u elastic:changeme https://elasticsearch:9200/_xpack/security/role
{
[... default roles ...]
"test_role": {
"cluster": [
"monitor"
],
"indices": [
{
"names": [
"*"
],
"privileges": [
"monitor",
"delete_index"
]
}
],
"run_as": ,
"metadata": {}
}
}
All good so far, however when creating a user:
curl -XPOST -k -u elastic:changeme https://elasticsearch:9200/_xpack/security/user/test_user -d '
{
"password" : "changeme",
"roles" : [ "test_role" ],
"full_name" : "Test User",
"email" : "testuser@example.com"
}'
result:
{"error":{"root_cause":[{"type":"illegal_state_exception","reason":"user cannot be created or changed as the user service cannot write until template and mappings are up to date"}],"type":"illegal_state_exception","reason":"user cannot be created or changed as the user service cannot write until template and mappings are up to date"},"status":500}
Elasticsearch log:
[2017-07-27T21:41:53,472][DEBUG][o.e.x.s.a.s.NativeRolesStore] [es-master-0] mapping for security index not up to date, so service cannot start
[2017-07-27T21:41:53,564][DEBUG][o.e.x.s.a.s.NativeRolesStore] [es-master-0] mapping for security index not up to date, so service cannot start
[2017-07-27T21:41:53,618][DEBUG][o.e.x.s.a.s.NativeRolesStore] [es-master-0] mapping for security index not up to date, so service cannot start
...
The content of .security
index:
curl -k -u elastic:changeme https://elasticsearch:9200/.security/_search
{"took":30,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":1,"max_score":1.0,"hits":[{"_index":".security","_type":"role","_id":"test_role","_score":1.0,"_source":{"cluster":["monitor"],"indices":[{"names":["*"],"privileges":["monitor","delete_index"]}],"run_as":,"metadata":{}}}]}}
Worth noting that existing cluster on which I'm trying to enable x-pack was upgraded from version 2.4.1 to 5.1.1. Could this be a reason?
I also tried a brand new cluster deployment (no pre-existing indexes) and was able to successfully create role and user, with the relevant logs below:
[2017-07-27T16:26:59,524][DEBUG][o.e.x.s.a.s.NativeRolesStore] [es-client-0] native roles store waiting until gateway has recovered from disk
[2017-07-27T16:26:59,524][DEBUG][o.e.x.s.a.s.NativeRolesStore] [es-client-0] security template [security-index-template] does not exist or is not up to date, so service cannot start
[2017-07-27T16:27:05,777][DEBUG][o.e.x.s.a.s.NativeRolesStore] [es-client-0] security template [security-index-template] does not exist or is not up to date, so service cannot start
[2017-07-27T16:27:05,777][DEBUG][o.e.x.s.a.s.NativeRolesStore] [es-client-0] security template [security-index-template] does not exist or is not up to date, so service cannot start
[2017-07-27T16:27:05,777][DEBUG][o.e.x.s.a.s.NativeRolesStore] [es-client-0] security template [security-index-template] does not exist or is not up to date, so service cannot start
[2017-07-27T16:27:06,261][DEBUG][o.e.x.s.a.s.NativeRolesStore] [es-client-0] security index [.security] does not exist, so service can start
[2017-07-27T16:28:12,320][DEBUG][o.e.x.s.a.s.NativeRolesStore] [es-client-0] invalidating role [my_role] in cache
[2017-07-27T16:28:46,441][INFO ][o.e.x.s.a.u.TransportPutUserAction] [es-client-0] added user [my_user]
Any ideas on how to debug it further will be greatly appreciated. Thanks.