# Ansible for Solr distributed shard deployment

**URL:** <https://forum.ansible.com/t/ansible-for-solr-distributed-shard-deployment/13130>\
**Category:** Ansible Project\
**Created:** [July 16, 2013, 2:43am UTC](https://forum.ansible.com/t/ansible-for-solr-distributed-shard-deployment/13130 "2013-07-16T02:43:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kavin\_Kankeshwar](https://avatars.discourse-cdn.com/v4/letter/k/35a633/32.png) [@Kavin\_Kankeshwar](https://forum.ansible.com/u/Kavin_Kankeshwar)\
**Post date:** [July 16, 2013, 2:43am UTC](https://forum.ansible.com/t/ansible-for-solr-distributed-shard-deployment/13130/1 "2013-07-16T02:43:12Z")

</div>

Hi,

Are there any examples/best practices of using Ansible to deploy Solr distributed index on multiple shards ? I looked at Ansible examples repo, Did not find anything related to it.

Regards,

---

<div class="post-metadata">

**Author:** ![Guillaume\_Belrose](https://avatars.discourse-cdn.com/v4/letter/g/3d9bf3/32.png) [@Guillaume\_Belrose](https://forum.ansible.com/u/Guillaume_Belrose)\
**Post date:** [July 16, 2013, 7:57am UTC](https://forum.ansible.com/t/ansible-for-solr-distributed-shard-deployment/13130/2 "2013-07-16T07:57:39Z")

</div>

Hi,

Are you referring to SolrCloud ([http://wiki.apache.org/solr/SolrCloud](http://wiki.apache.org/solr/SolrCloud))?

I’ve used Ansible to deploy a single Solr instance from scratch and that was quite easy to do. I’ve ended up creating playbooks to install the JDK (Oracle or OpenJDK), Jetty, the Solr Web app, and finally the Solr config files (schema.xml, etc…)

Assuming you want to deploy SolrCloud, you probably have to deploy a Zookeeper cluster, which is not that hard with Ansible.

Have a look at this example ([https://github.com/ansible/ansible-examples/tree/master/hadoop](https://github.com/ansible/ansible-examples/tree/master/hadoop)) on how to deploy a Hadoop cluster with Ansible. This covers how to install the JDK and setup a Zookeeper cluster.

What is very nice about Ansible is that you can easily and quickly translate instructions written in English into working playbooks.

My Solr play book is as simple as the following (but you might want to do things differently).

```auto
---
# Ansible task file to install Jetty8. Must be used in combination with the jdk7 task.
- name: Ensure that rsync is installed.
  action: yum name=rsync state=installed

- name: Copy the Jetty8 rpm.
  action: copy src=../roles/solr/files/jetty-rpm-8.1.9.v20130131.rpm dest=/tmp/

- name: Install the Jetty8 rpm.
  action: yum name=/tmp/jetty-rpm-8.1.9.v20130131.rpm state=installed

- name: Copy the solr war to /opt/jetty/webapps/
  action: copy src=../roles/solr/files/solr-3.6.2.war dest=/opt/jetty/webapps/solr.war  

- name: Copy the jetty.xml config file to /opt/jetty/etc/
  action: template src=../roles/solr/templates/jetty.xml.j2 dest=/opt/jetty/etc/jetty.xml

- name: Recursively copy the solr folder via rsync to /opt/jetty/
  local_action: shell rsync -av -e "ssh" --rsync-path="sudo rsync" ../roles/solr/files/solr/ quantel@$inventory_hostname:/opt/jetty/solr/
  sudo: False

- name: Start Jetty, and ensure it is started at boot time.
  action: service name=jetty state=started enabled=yes
  async: 60
  poll : 0

```

I hope this helps.

G.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [July 16, 2013, 11:47am UTC](https://forum.ansible.com/t/ansible-for-solr-distributed-shard-deployment/13130/3 "2013-07-16T11:47:42Z")

</div>

Yeah we don’t have anything up for Solr (or ElasticSearch, etc) right now.

---

<div class="post-metadata">

**Author:** ![Marcelo\_Costa](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@Marcelo\_Costa](https://forum.ansible.com/u/Marcelo_Costa)\
**Post date:** [July 16, 2013, 12:18pm UTC](https://forum.ansible.com/t/ansible-for-solr-distributed-shard-deployment/13130/4 "2013-07-16T12:18:06Z")

</div>

Very cool

Marcelo Costa

---

<div class="post-metadata">

**Author:** ![Kavin\_Kankeshwar](https://avatars.discourse-cdn.com/v4/letter/k/35a633/32.png) [@Kavin\_Kankeshwar](https://forum.ansible.com/u/Kavin_Kankeshwar)\
**Post date:** [July 16, 2013, 5:44pm UTC](https://forum.ansible.com/t/ansible-for-solr-distributed-shard-deployment/13130/5 "2013-07-16T17:44:09Z")

</div>

Thanks for the info, This is good! Yes its about deploying SolrCloud .

Regards,
