# Multiple indices while defining a role using Elastic Search - Ansible role

**URL:** <https://discuss.elastic.co/t/multiple-indices-while-defining-a-role-using-elastic-search-ansible-role/172292>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-security\
**Created:** [March 14, 2019, 9:38am UTC](https://discuss.elastic.co/t/multiple-indices-while-defining-a-role-using-elastic-search-ansible-role/172292 "2019-03-14T09:38:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Waseem\_Tabraze](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/waseem_tabraze/32/41967_2.png) [@Waseem\_Tabraze](https://discuss.elastic.co/u/Waseem_Tabraze)\
**Post date:** [March 14, 2019, 9:38am UTC](https://discuss.elastic.co/t/multiple-indices-while-defining-a-role-using-elastic-search-ansible-role/172292/1 "2019-03-14T09:38:56Z")

</div>

Is there a way to add multiple indices while defining a role using `ansible-elasticsearch` role.  
I tried doing this but in vain.

```
es_roles:
  native:
     indices:
       - names: 'index1, index2'
         privileges:
           - read

```

Though we can define the indices as shown below, I'm looking for a more clean solution as we've large number of indices.

```
es_roles:
  indices:
    - names: 'index1'
      privileges:
        - read
    - names: 'index2'
      privileges:
        - read
```

---

<div class="post-metadata">

**Author:** ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)\
**Post date:** [March 14, 2019, 10:29am UTC](https://discuss.elastic.co/t/multiple-indices-while-defining-a-role-using-elastic-search-ansible-role/172292/2 "2019-03-14T10:29:06Z")

</div>

Dd you try this:

```auto
es_roles:
  native:
    indices:
      - names:
          - 'index1'
          - 'index2'
        privileges: 
          - read

```

---

<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:** [April 11, 2019, 10:29am UTC](https://discuss.elastic.co/t/multiple-indices-while-defining-a-role-using-elastic-search-ansible-role/172292/3 "2019-04-11T10:29:15Z")

</div>

Closed on April 11, 2019, 10:29am UTC

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