# Create user automatically

**URL:** <https://discuss.elastic.co/t/create-user-automatically/127432>\
**Category:** Elasticsearch\
**Created:** [April 10, 2018, 7:16am UTC](https://discuss.elastic.co/t/create-user-automatically/127432 "2018-04-10T07:16:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![flochon](https://avatars.discourse-cdn.com/v4/letter/f/e19b73/32.png) [@flochon](https://discuss.elastic.co/u/flochon)\
**Post date:** [April 10, 2018, 7:16am UTC](https://discuss.elastic.co/t/create-user-automatically/127432/1 "2018-04-10T07:16:35Z")

</div>

I would like add a user when I throw the script Ansible. I took the official script here : [https://github.com/elastic/ansible-elasticsearch](https://github.com/elastic/ansible-elasticsearch)

I make this for the new user :

```auto
es_users:
  native:
    kibana:
      password: totototo
    logstash_system:
      password: totototo
    elastic:
      password: totototo
    logstash_internal:
      password: totototo
      roles:
        - logstash_writer

es_roles:
  native:
    logstash_writer:
      cluster:
        - manage_index_templates
        - monitor
      indices:
        - names: 'filebeat-*'
          privileges:
            - write
            - delete
            - create-index

```

The problem is Logstash\_internal doesn't work and if I create manually with the Dev Tools the same user with the same role it's work. What's wrong ?

---

<div class="post-metadata">

**Author:** ![michael.russell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael.russell/32/27889_2.png) [@michael.russell](https://discuss.elastic.co/u/michael.russell)\
**Post date:** [April 11, 2018, 7:13am UTC](https://discuss.elastic.co/t/create-user-automatically/127432/2 "2018-04-11T07:13:27Z")

</div>

Hi @flochon!

> [@flochon](#):
>
> The problem is Logstash\_internal doesn't work

Could you expand a bit more on what errors you are getting or what functionality isn't working exactly?

When I took your configuration and ran it locally I got this error:

```auto
kitchen@6dc520f8504e:~$ curl -s -u logstash_internal:totototo localhost:9200 | json_pp
{
   "status" : 400,
   "error" : {
      "type" : "illegal_argument_exception",
      "root_cause" : [
         {
            "reason" : "unknown index privilege [create-index]. a privilege must be either one of the predefined fixed indices privileges [all=[all],read=[read],create_index=[create_index],read_cross_cluster=[read_cross_cluster],index=[index],monitor=[monitor],none=[none],delete=[delete],manage=[manage],delete_index=[delete_index],view_index_metadata=[view_index_metadata],create=[create],write=[write]] or a pattern over one of the available index actions",
            "type" : "illegal_argument_exception"
         }
      ],
      "reason" : "unknown index privilege [create-index]. a privilege must be either one of the predefined fixed indices privileges [all=[all],read=[read],create_index=[create_index],read_cross_cluster=[read_cross_cluster],index=[index],monitor=[monitor],none=[none],delete=[delete],manage=[manage],delete_index=[delete_index],view_index_metadata=[view_index_metadata],create=[create],write=[write]] or a pattern over one of the available index actions"
   }
}

```

So it looks like you made a typo and need to rename `create-index` to `create_index`. You can find the full list of available permissions on the [x-pack security privileges documentation](https://www.elastic.co/guide/en/x-pack/current/security-privileges.html) page.

---

<div class="post-metadata">

**Author:** ![flochon](https://avatars.discourse-cdn.com/v4/letter/f/e19b73/32.png) [@flochon](https://discuss.elastic.co/u/flochon)\
**Post date:** [April 11, 2018, 8:19am UTC](https://discuss.elastic.co/t/create-user-automatically/127432/3 "2018-04-11T08:19:48Z")

</div>

Yes, you're right. I did a stupid mistake.

Thank you very much.

---

<div class="post-metadata">

**Author:** ![michael.russell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael.russell/32/27889_2.png) [@michael.russell](https://discuss.elastic.co/u/michael.russell)\
**Post date:** [April 11, 2018, 8:42am UTC](https://discuss.elastic.co/t/create-user-automatically/127432/4 "2018-04-11T08:42:40Z")

</div>

> [@flochon](#):
>
> Yes, you're right. I did a stupid mistake.
> 
> Thank you very much.

Awesome! Glad you got it working 🙂

---

<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:** [May 9, 2018, 8:43am UTC](https://discuss.elastic.co/t/create-user-automatically/127432/5 "2018-05-09T08:43:12Z")

</div>

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