# Deploying a 3 nodes cluster with ansible

**URL:** <https://discuss.elastic.co/t/deploying-a-3-nodes-cluster-with-ansible/63262>\
**Category:** Elasticsearch\
**Created:** [October 18, 2016, 9:01am UTC](https://discuss.elastic.co/t/deploying-a-3-nodes-cluster-with-ansible/63262 "2016-10-18T09:01:30Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![trenzalore](https://avatars.discourse-cdn.com/v4/letter/t/ac91a4/32.png) [@trenzalore](https://discuss.elastic.co/u/trenzalore)\
**Post date:** [October 18, 2016, 9:01am UTC](https://discuss.elastic.co/t/deploying-a-3-nodes-cluster-with-ansible/63262/1 "2016-10-18T09:01:30Z")

</div>

Hi !

I would like to deploy a 3 nodes cluster with ansible. (I'm new in the ansible world)  
I would like to know if the playbook I made will answer all my requests.

My requests are:

- deploy elasticsearch and logstash to 3 servers.
- whenever a server break, I just need to launch the playbook so a new elasticsearch and logstash instance are installed in the new server and are added to the current cluster. (i don't backup the servers, so I need to reinstall when one break)

The roles I use are the official elacticsearch roles and for logstash: [https://github.com/CyVerse-Ansible/ansible-logstash](https://github.com/CyVerse-Ansible/ansible-logstash)

Here is my playbook: [https://gist.github.com/newclem/494d99c3815b1d32f15a6f038f0c92f1](https://gist.github.com/newclem/494d99c3815b1d32f15a6f038f0c92f1)

Thank you !

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [October 18, 2016, 9:09am UTC](https://discuss.elastic.co/t/deploying-a-3-nodes-cluster-with-ansible/63262/2 "2016-10-18T09:09:45Z")

</div>

You should test whether it works. I can offer a few comments:

> discovery.zen.ping.unicast.hosts: "liprd072:9300,liprd073,9300",

The last comma should of course be a colon.

You shouldn't have three nearly identical plays in the playbook. Use a single play that acts on all hosts. If they need different variables then use group\_vars and/or host\_vars to use different values for each host.

I'm pretty sure that discovery.zen.ping.unicast.hosts can always list all hostnames, i.e. you don't have to be picky about not listing a node's own hostname.

You're listing discovery.zen.ping.multicast.enabled twice for each es\_config role.

---

<div class="post-metadata">

**Author:** ![trenzalore](https://avatars.discourse-cdn.com/v4/letter/t/ac91a4/32.png) [@trenzalore](https://discuss.elastic.co/u/trenzalore)\
**Post date:** [October 18, 2016, 12:13pm UTC](https://discuss.elastic.co/t/deploying-a-3-nodes-cluster-with-ansible/63262/3 "2016-10-18T12:13:04Z")

</div>

Thank you for your reply.

I've updated my play: [https://gist.github.com/newclem/494d99c3815b1d32f15a6f038f0c92f1](https://gist.github.com/newclem/494d99c3815b1d32f15a6f038f0c92f1)

And in the inventory I put a host var. hosts\_unicast=liprd071:9300,liprd71:9300 (each var are different for each host)

Am I doing it right ?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [October 19, 2016, 5:30am UTC](https://discuss.elastic.co/t/deploying-a-3-nodes-cluster-with-ansible/63262/4 "2016-10-19T05:30:07Z")

</div>

Yeah, you're on the right track.

Note that the `groups` dictionary contains a mapping of all inventory groups and their members, so instead of defining a separate variable that lists the hostnames and referencing it when you set the unicast host list you can say `groups['nodes']`.

But this is more about Ansible than Elasticsearch so I'll stop here.

---

<div class="post-metadata">

**Author:** ![trenzalore](https://avatars.discourse-cdn.com/v4/letter/t/ac91a4/32.png) [@trenzalore](https://discuss.elastic.co/u/trenzalore)\
**Post date:** [October 20, 2016, 2:18pm UTC](https://discuss.elastic.co/t/deploying-a-3-nodes-cluster-with-ansible/63262/5 "2016-10-20T14:18:12Z")

</div>

Okay thank you for your reply.

I launched the playbook and everything have been installed but I have now 2 problems:

1. There is no elasticsearch service. Elastic search is launched with and not as a service
2. My nodes are alone, the unicast discover doesn't work. I have 3 nodes but there not in the same cluster. How do I make it works ?

Thank you !

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [October 20, 2016, 2:23pm UTC](https://discuss.elastic.co/t/deploying-a-3-nodes-cluster-with-ansible/63262/6 "2016-10-20T14:23:24Z")

</div>

1. I don't understand the question. There appears to be a word missing.
2. What's in the ES logs? Is ES listening to the right interfaces? As of 2.0 it's only listening on localhost by default.

---

<div class="post-metadata">

**Author:** ![trenzalore](https://avatars.discourse-cdn.com/v4/letter/t/ac91a4/32.png) [@trenzalore](https://discuss.elastic.co/u/trenzalore)\
**Post date:** [October 20, 2016, 2:44pm UTC](https://discuss.elastic.co/t/deploying-a-3-nodes-cluster-with-ansible/63262/7 "2016-10-20T14:44:51Z")

</div>

1. Oups sorry, the word was Java.

2. I put network.host: _eth0_

If read well, I should put a publish\_adress wich is the ip adress of the server ?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [October 20, 2016, 2:57pm UTC](https://discuss.elastic.co/t/deploying-a-3-nodes-cluster-with-ansible/63262/8 "2016-10-20T14:57:19Z")

</div>

1. Okay. It sounds weird that the playbook doesn't start ES via `service elasticsearch start` but I don't have time to dig into this.
2. Your logs indicate that you're only binding to localhost.

---

<div class="post-metadata">

**Author:** ![trenzalore](https://avatars.discourse-cdn.com/v4/letter/t/ac91a4/32.png) [@trenzalore](https://discuss.elastic.co/u/trenzalore)\
**Post date:** [October 20, 2016, 3:00pm UTC](https://discuss.elastic.co/t/deploying-a-3-nodes-cluster-with-ansible/63262/9 "2016-10-20T15:00:21Z")

</div>

1. In fact the service elasticsearch doesn't exists but a script called node1-elasticsearch exists in /etc/default. (or node2-elasticsearch, etc.)
2. Okay I'll set this up and I'll come back. Thank you

EDIT: I don't know how to bind to another adress. I put network.host: _site_ and it still bind to localhost. Do i have do specify the IP adress ?

EDIT2: The log are not up to date, I don't know why. And I can't apt-get remove elasticsearch... Something doesn't work well..

EDIT3: All my servers are down, I have to rebuild them.

---

<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:** [July 5, 2017, 10:10pm UTC](https://discuss.elastic.co/t/deploying-a-3-nodes-cluster-with-ansible/63262/10 "2017-07-05T22:10:33Z")

</div>


