Ansible for Solr distributed shard deployment

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,

Hi,

Are you referring to 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) 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).

---
# 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.

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

Very cool

Marcelo Costa

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

Regards,