diff --git a/solr-tomcat-core-conf/defaults/main.yml b/solr-tomcat-core-conf/defaults/main.yml new file mode 100644 index 00000000..ca445377 --- /dev/null +++ b/solr-tomcat-core-conf/defaults/main.yml @@ -0,0 +1,32 @@ +--- +solr_http_port: 8983 +tomcat_load_additional_default_conf: True +tomcat_version: 7 +# solr needs a lot of time to start if it needs to rebuild its indices +tomcat_restart_timeout: 100000 + +solr_service: -solr +solr_config_name: hindex +solr_shards: 1 +solr_instance: '{{ solr_service }}' +solr_log_level: INFO +solr_http_port_1: '{{ solr_http_port }}' +solr_zoo_port: 9983 +solr_zoo_port_1: 9984 +solr_zoo_port_2: 9985 +solr_jmx_port_1: 8601 +solr_user: '{{ tomcat_user }}' +solr_group: '{{ tomcat_user }}' +solr_outside_tomcat_dir: False +# We need to define this one because we are using the tomcat multiple instances role +solr_tomcat_instance_dir: '{{ tomcat_m_instances_base_path }}/{{ solr_http_port }}' +solr_data_dir: '{{ solr_tomcat_instance_dir }}/solr' +solr_collections_base_dir: '{{ solr_data_dir }}/data/solr' +solr_zookeeper_data_dir: '{{ solr_data_dir }}/zoo_data' +solr_install_collection1: False + +# Define the following if you want a multicore installation +solr_multicore: False +solr_global_cores: + - collection1 + diff --git a/solr-tomcat-core-conf/files/solr_core_base.tar.gz b/solr-tomcat-core-conf/files/solr_core_base.tar.gz new file mode 100644 index 00000000..8465587f Binary files /dev/null and b/solr-tomcat-core-conf/files/solr_core_base.tar.gz differ diff --git a/solr-tomcat-core-conf/handlers/main.yml b/solr-tomcat-core-conf/handlers/main.yml new file mode 100644 index 00000000..b013a95f --- /dev/null +++ b/solr-tomcat-core-conf/handlers/main.yml @@ -0,0 +1,4 @@ +--- +- name: tomcat solr restart + service: name=tomcat-instance-{{ solr_http_port }} state=restarted sleep=20 + diff --git a/solr-tomcat-core-conf/tasks/main.yml b/solr-tomcat-core-conf/tasks/main.yml new file mode 100644 index 00000000..bc828ef5 --- /dev/null +++ b/solr-tomcat-core-conf/tasks/main.yml @@ -0,0 +1,25 @@ +--- +- block: + - name: Create the solr cores data directories + file: dest={{ solr_collections_base_dir }}/{{ item }} state=directory owner={{ solr_user }} group={{ solr_user }} + with_items: '{{ solr_cores }}' + + - name: Install the solr cores data on a multicore system + unarchive: src={{ solr_data_dir }}/collection_data/solr_core_base.tar.gz dest={{ solr_data_dir }}/data/solr/{{ item }} copy=no + args: + creates: '{{ solr_data_dir }}/data/solr/{{ item }}/conf/solrconfig.xml' + with_items: '{{ solr_global_cores }}' + notify: tomcat solr restart + + - name: Install the solr.xml file + template: src={{ item }}.j2 dest={{ solr_data_dir }}/data/solr/{{ item }} owner=root group={{ solr_user }} mode=0440 + with_items: + - solr.xml + notify: tomcat solr restart + + - name: Fix the cores permissions + file: path={{ solr_collections_base_dir }} owner={{ solr_user }} group={{ solr_user }} recurse=yes + + when: solr_multicore is defined and solr_multicore + tags: [ solr, tomcat, solr_core ] + diff --git a/solr-tomcat-core-conf/templates/solr.xml.j2 b/solr-tomcat-core-conf/templates/solr.xml.j2 new file mode 100644 index 00000000..20968a26 --- /dev/null +++ b/solr-tomcat-core-conf/templates/solr.xml.j2 @@ -0,0 +1,59 @@ + + + + + + + + + {% if not solr_multicore %} + {{ ansible_fqdn }} + {{ solr_http_port_1 }} + ${hostContext:solr} + ${zkClientTimeout:30000} + ${genericCoreNodeNames:true} + {% endif %} + + + + ${socketTimeout:0} + ${connTimeout:0} + + + {% if solr_multicore %} + + {% for core in solr_global_cores %} + + + + + + {% endfor %} + + {% endif %} + + +