# Cannot import template in elasticsearch

**URL:** <https://discuss.elastic.co/t/cannot-import-template-in-elasticsearch/264655>\
**Category:** Elasticsearch\
**Created:** [February 18, 2021, 7:13am UTC](https://discuss.elastic.co/t/cannot-import-template-in-elasticsearch/264655 "2021-02-18T07:13:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Voula\_Mikr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/voula_mikr/32/58451_2.png) [@Voula\_Mikr](https://discuss.elastic.co/u/Voula_Mikr)\
**Post date:** [February 18, 2021, 7:13am UTC](https://discuss.elastic.co/t/cannot-import-template-in-elasticsearch/264655/1 "2021-02-18T07:13:35Z")

</div>

Hi  
I have an Elasticsearch with SearchGuard mechanism on.  
In searchguard configuration there is pmadmin role with the below permissions in sg\_roles.yml :  
sgs\_pmadmin\_role:  
cluster\_permissions:  
- SGS\_CLUSTER\_MONITOR  
- SGS\_CLUSTER\_COMPOSITE\_OPS\_RO  
index\_permissions:  
- index\_patterns:  
- "pm\*"  
- ".kibana\*"  
allowed\_actions:  
- SGS\_CRUD  
- SGS\_CREATE\_INDEX  
- SGS\_MANAGE

...and in sg\_roles\_mapping.yml:  
sgs\_pmadmin\_role:  
reserved: true  
users:  
- "pmadmin"

I am trying to import a template for a non existing index pm-counters\* and I get the below:

curl -X PUT -k "https://:9200/\_index\_template/template\_1?pretty" -H 'Content-Type: application/json' -d'{"index\_patterns": "pm-counters\*","template":{"settings": { "number\_of\_shards": 1 } } } '  
{  
"error" : {  
"root\_cause" : [  
{  
"type" : "security\_exception",  
"reason" : "no permissions for [indices:admin/index\_template/put] and User [name=pmadmin, backend\_roles=, requestedTenant=null]"  
}  
],  
"type" : "security\_exception",  
"reason" : "no permissions for [indices:admin/index\_template/put] and User [name=pmadmin, backend\_roles=, requestedTenant=null]"  
},  
"status" : 403  
}

I change the configuration to the below:  
sgs\_pmadmin\_role:  
cluster\_permissions:  
- SGS\_CLUSTER\_MANAGE\_INDEX\_TEMPLATES  
- SGS\_CLUSTER\_MONITOR  
- SGS\_CLUSTER\_COMPOSITE\_OPS\_RO  
- SGS\_CLUSTER\_ALL  
index\_permissions:  
- index\_patterns:  
- "pm-counters\*"  
- ".kibana\*"  
allowed\_actions:  
- SGS\_CRUD  
- SGS\_CREATE\_INDEX  
- SGS\_MANAGE  
- SGS\_INDICES\_ALL

but with same results.

I tried the same command with "admin" and succeed,  
where admin :  
\_sg\_meta:  
type: "rolesmapping"  
config\_version: 2  
SGS\_ALL\_ACCESS:  
reserved: true  
hidden: false  
backend\_roles:  
- "admin"

What should be the permissions or the configuration generally for pmadmin to be able to import a template?  
Thank you in advance!

---

<div class="post-metadata">

**Author:** ![Wolfram\_Haussig](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wolfram_haussig/32/70528_2.png) [@Wolfram\_Haussig](https://discuss.elastic.co/u/Wolfram_Haussig)\
**Post date:** [February 18, 2021, 7:26am UTC](https://discuss.elastic.co/t/cannot-import-template-in-elasticsearch/264655/2 "2021-02-18T07:26:46Z")

</div>

Hello Voula,

Have a look here: [Security privileges | Elasticsearch Reference [7.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-privileges.html)

You need the `manage_index_templates` cluster privilege although I do not know how that maps to Search Guard.

Best regards  
Wolfram

---

<div class="post-metadata">

**Author:** ![Voula\_Mikr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/voula_mikr/32/58451_2.png) [@Voula\_Mikr](https://discuss.elastic.co/u/Voula_Mikr)\
**Post date:** [February 18, 2021, 12:36pm UTC](https://discuss.elastic.co/t/cannot-import-template-in-elasticsearch/264655/3 "2021-02-18T12:36:22Z")

</div>

Hi,

Thank you for the prompt answer.  
I get some error responses as below:  
no permissions for [indices:data/write/index]  
no permissions for [indices:admin/index\_template/put]  
What are "data" and "admin" in the above errors?  
Is there any page I can get more info about that?  
Thanks again!

---

<div class="post-metadata">

**Author:** ![Wolfram\_Haussig](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wolfram_haussig/32/70528_2.png) [@Wolfram\_Haussig](https://discuss.elastic.co/u/Wolfram_Haussig)\
**Post date:** [February 18, 2021, 12:50pm UTC](https://discuss.elastic.co/t/cannot-import-template-in-elasticsearch/264655/4 "2021-02-18T12:50:32Z")

</div>

Hi,

> [@Voula\_Mikr](#):
>
> What are "data" and "admin" in the above errors?

I guess that this is to differentiate between data(documents) and metadata(mapping, templates,...).

In the link I posted above there are the following descriptions:  
For `write`:

> Privilege to perform all write operations to documents, which includes the permission to index, update, and delete documents as well as performing bulk operations, and allows the [dynamic mapping updates](https://www.elastic.co/guide/en/elasticsearch/reference/7.11/dynamic-mapping.html) as a result of these.

For `manage`:

> All `monitor` privileges plus index and data stream administration (aliases, analyze, cache clear, close, delete, exists, flush, mapping, open, force merge, refresh, settings, search shards, **templates** , validate).

So you might need those too. On which version are you anyway?

Also, you could have a look into the REST API documentation: [Create or update index template API | Elasticsearch Guide [8.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-template.html)

> - If the Elasticsearch security features are enabled, you must have the `manage_index_templates` or `manage` [cluster privilege](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-privileges.html#privileges-list-cluster) to use this API.

I don't know if this is valid if you have SearchGuard instead of Elastic Security on...

Best regards  
Wolfram

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [February 18, 2021, 10:05pm UTC](https://discuss.elastic.co/t/cannot-import-template-in-elasticsearch/264655/5 "2021-02-18T22:05:03Z")

</div>

I'd recommend you run our free, native Security functionality as we can provide direct assistance with that.

Otherwise you will need to contact searchguard sorry.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 18, 2021, 10:05pm UTC](https://discuss.elastic.co/t/cannot-import-template-in-elasticsearch/264655/6 "2021-03-18T22:05:10Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
